Changeset 1569 for trunk


Ignore:
Timestamp:
01/16/12 08:22:51 (16 months ago)
Author:
philmoz
Message:

Update trunk with latest changes from reyalp-flt branch.

Location:
trunk
Files:
4 deleted
68 edited
5 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/CHDK/LANG/english.lng

    r1568 r1569  
    587587473 "Options" 
    588588 
     589474 "Select keyboard profile" 
     590475 "Load keyboard profile" 
     591476 "More ->" 
     592477 "Make dir" 
     593478 "Rename" 
     594479 "Enter name of directory:" 
     595480 "Enter new name of file:" 
  • trunk/Makefile

    r1505 r1569  
    123123        zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)CHDK/SCRIPTS/EDITOR/*   > $(DEVNULL) 
    124124        zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)CHDK/syscurves.CVF      > $(DEVNULL) 
     125        zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)CHDK/russian.key        > $(DEVNULL) 
    125126        zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)doc/changelog.txt  > $(DEVNULL) 
    126127        zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)doc/changelog.txt  > $(DEVNULL) 
  • trunk/core/Makefile

    r1568 r1569  
    1818 
    1919OPT_OBJS= 
     20ifdef OPT_GAMES 
     21CFLAGS+=-DOPT_GAMES 
     22endif 
    2023ifdef OPT_CURVES 
    2124CFLAGS+=-DOPT_CURVES 
    22 #OPT_OBJS+=curves.o 
    2325endif 
    2426ifdef OPT_TEXTREADER 
    2527CFLAGS+=-DOPT_TEXTREADER 
    26 #OPT_OBJS+=gui_read.o  
     28endif 
     29ifdef OPT_CALENDAR 
     30CFLAGS+=-DOPT_CALENDAR 
    2731endif 
    2832ifdef OPT_DEBUGGING 
     
    3943endif  
    4044ifdef OPT_SCRIPTING 
    41 OPT_OBJS+=motion_detector.o script.o 
     45OPT_OBJS+=script.o 
    4246endif  
    4347ifdef OPT_LUA 
     
    6064     gui.o kbd.o action_stack.o conf.o module_wrappers.o module_exportlist.o \ 
    6165     histogram.o gui_batt.o gui_space.o gui_osd.o raw.o \ 
    62      gui_usb.o gui_lang.o gui_grid.o modules.o module_load.o\ 
    63      levent.o shot_histogram.o bitvector.o console.o\ 
     66     gui_usb.o gui_lang.o modules.o module_load.o \ 
     67     levent.o shot_histogram.o console.o \ 
    6468     usb_input.o usb_module.o usb_remote.o $(OPT_OBJS) 
    6569 
     
    103107module_exportlist.h: $(topdir)tools/makeexport$(EXE) module_exportlist.c 
    104108        @echo $< \-\> $@ 
    105         $(topdir)tools/makeexport$(EXE) module_exportlist.c module_exportlist.h modules/exportlist.txt 
     109        $(topdir)tools/makeexport$(EXE) module_exportlist.c module_exportlist.h modules/exportlist.txt module_hashlist.h 
    106110 
    107111flt.h: $(topdir)tools/elf2flt/flt.h 
  • trunk/core/conf.c

    r1568 r1569  
    77#include "raw.h" 
    88#include "modules.h" 
     9#include "module_load.h" 
    910#include "gui_draw.h" 
    1011#include "gui_osd.h" 
     
    1718//------------------------------------------------------------------- 
    1819#define CONF_FILE  "A/CHDK/CCHDK.CFG" 
    19 #define CONF_MAGICK_VALUE (0x33204741) 
    20  
    21 #define CONF_INFO(id, param, type, def, func) { id, sizeof( param ), type, &param, {def}/*, func*/ } 
    22  
    23  
    24 //------------------------------------------------------------------- 
    25 typedef struct { 
    26     unsigned short      id; 
    27     unsigned char       size; 
    28     char                type; 
    29     void                *var; 
    30     union { 
    31         void            *ptr; 
    32         int             i; 
    33         color           cl; 
    34     }; 
    35     // Since only a few of the ConfInfo entries have a 'func' it saves space to not store the function addresses in the ConfInfo struct 
    36     // handled in conf_info_func code 
    37     //void                (*func)(); 
    38 } ConfInfo; 
    39  
    40 //------------------------------------------------------------------- 
    41 Conf conf; 
     20#define CONF_MAGICK_VALUE   (0x33204741) 
     21 
     22//------------------------------------------------------------------- 
     23Conf conf = { MAKE_API_VERSION(2,0) }; 
    4224 
    4325int state_shooting_progress = SHOOTING_PROGRESS_NONE; 
     
    7153static void conf_change_menu_symbol_rbf_file(); 
    7254static void conf_change_alt_mode_button(); 
    73 static void conf_change_grid_file(); 
    7455static void conf_change_video_bitrate(); 
    7556static void conf_change_dng_ext(); 
     
    149130         shooting_video_bitrate_change(conf.video_bitrate); 
    150131        } 
    151         conf.edge_overlay_pano = 0; // reset it because otherwise this feature cant be used at startup (when buffer is empty) - needs workaround other than this! 
     132        //conf.edge_overlay_pano = 0; // reset it because otherwise this feature cant be used at startup (when buffer is empty) - needs workaround other than this! 
    152133} 
    153134 
     
    155136/* !!! Do NOT change ID for items defined already! Append a new one at the end! !!! */ 
    156137    CONF_INFO(  1, conf.show_osd,               CONF_DEF_VALUE, i:1, NULL), 
    157     CONF_INFO(  2, conf.save_raw,               CONF_DEF_VALUE, i:0, NULL), 
     138    CONF_INFO(  2, conf.save_raw,               CONF_DEF_VALUE, i:0, conf_change_dng), 
    158139    CONF_INFO(  3, conf.script_shoot_delay,     CONF_DEF_VALUE, i:0, NULL), 
    159140    CONF_INFO(  4, conf.show_histo,             CONF_DEF_VALUE, i:0, NULL), 
     
    184165    CONF_INFO( 29, conf.batt_icon_color,        CONF_DEF_VALUE, cl:COLOR_WHITE, NULL), 
    185166    CONF_INFO( 30, conf.menu_color,             CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL), 
    186     CONF_INFO( 31, conf.reader_color,           CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_GREY, COLOR_WHITE), NULL), 
     167    //CONF_INFO( 31, conf.reader_color,           CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_GREY, COLOR_WHITE), NULL), 
    187168    CONF_INFO( 32, conf.ricoh_ca1_mode,         CONF_DEF_VALUE, i:0, NULL), 
    188169    CONF_INFO( 33, conf.flashlight,             CONF_DEF_VALUE, i:0, NULL), 
     
    192173    CONF_INFO( 36, conf.raw_prefix,             CONF_DEF_VALUE, i:RAW_PREFIX_CRW, NULL), 
    193174    CONF_INFO( 37, conf.raw_ext,                CONF_DEF_VALUE, i:DEFAULT_RAW_EXT, NULL), 
    194     CONF_INFO( 38, conf.reader_file,            CONF_CHAR_PTR,   ptr:"A/CHDK/BOOKS/README.TXT", NULL), 
    195     CONF_INFO( 39, conf.reader_pos,             CONF_DEF_VALUE, i:0, NULL), 
    196     CONF_INFO( 40, conf.sokoban_level,          CONF_DEF_VALUE, i:0, NULL), 
     175    //CONF_INFO( 38, conf.reader_file,            CONF_CHAR_PTR,   ptr:"A/CHDK/BOOKS/README.TXT", NULL), 
     176    //CONF_INFO( 39, conf.reader_pos,             CONF_DEF_VALUE, i:0, NULL), 
     177    //CONF_INFO( 40, conf.sokoban_level,          CONF_DEF_VALUE, i:0, NULL), 
    197178    CONF_INFO( 41, conf.show_clock,             CONF_DEF_VALUE, i:2, NULL), 
    198179    CONF_INFO( 42, conf.clock_pos,              CONF_OSD_POS_PTR,   ptr:&def_clock_pos , NULL), 
    199     CONF_INFO( 43, conf.reader_autoscroll,      CONF_DEF_VALUE, i:0, NULL), 
    200     CONF_INFO( 44, conf.reader_autoscroll_delay,CONF_DEF_VALUE, i:5, NULL), 
    201     CONF_INFO( 45, conf.reader_rbf_file,        CONF_CHAR_PTR,   ptr:"", NULL), 
    202     CONF_INFO( 46, conf.reader_codepage,        CONF_DEF_VALUE, i:FONT_CP_WIN, NULL), 
     180    //CONF_INFO( 43, conf.reader_autoscroll,      CONF_DEF_VALUE, i:0, NULL), 
     181    //CONF_INFO( 44, conf.reader_autoscroll_delay,CONF_DEF_VALUE, i:5, NULL), 
     182    //CONF_INFO( 45, conf.reader_rbf_file,        CONF_CHAR_PTR,   ptr:"", NULL), 
     183    //CONF_INFO( 46, conf.reader_codepage,        CONF_DEF_VALUE, i:FONT_CP_WIN, NULL), 
    203184    CONF_INFO( 47, conf.splash_show,            CONF_DEF_VALUE, i:1, NULL), 
    204185    CONF_INFO( 48, conf.histo_color2,           CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_RED, COLOR_WHITE), NULL), 
    205186    CONF_INFO( 49, conf.zebra_draw,             CONF_DEF_VALUE, i:0, NULL), 
    206     CONF_INFO( 50, conf.zebra_mode,             CONF_DEF_VALUE, i:ZEBRA_MODE_BLINKED_2, NULL), 
    207     CONF_INFO( 51, conf.zebra_restore_screen,   CONF_DEF_VALUE, i:1, NULL), 
    208     CONF_INFO( 52, conf.zebra_restore_osd,      CONF_DEF_VALUE, i:1, NULL), 
    209     CONF_INFO( 53, conf.zebra_over,             CONF_DEF_VALUE, i:1, NULL), 
    210     CONF_INFO( 54, conf.zebra_under,            CONF_DEF_VALUE, i:0, NULL), 
    211     CONF_INFO( 55, conf.zebra_color,            CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_RED, COLOR_RED), NULL), 
    212     CONF_INFO( 56, conf.zebra_draw_osd,         CONF_DEF_VALUE, i:ZEBRA_DRAW_HISTO, NULL), 
     187    //CONF_INFO( 50, conf.zebra_mode,             CONF_DEF_VALUE, i:ZEBRA_MODE_BLINKED_2, NULL), 
     188    //CONF_INFO( 51, conf.zebra_restore_screen,   CONF_DEF_VALUE, i:1, NULL), 
     189    //CONF_INFO( 52, conf.zebra_restore_osd,      CONF_DEF_VALUE, i:1, NULL), 
     190    //CONF_INFO( 53, conf.zebra_over,             CONF_DEF_VALUE, i:1, NULL), 
     191    //CONF_INFO( 54, conf.zebra_under,            CONF_DEF_VALUE, i:0, NULL), 
     192    //CONF_INFO( 55, conf.zebra_color,            CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_RED, COLOR_RED), NULL), 
     193    //CONF_INFO( 56, conf.zebra_draw_osd,         CONF_DEF_VALUE, i:ZEBRA_DRAW_HISTO, NULL), 
    213194    CONF_INFO( 57, conf.user_menu_as_root,      CONF_DEF_VALUE, i:0, NULL), 
    214195    CONF_INFO( 58, conf.zoom_value,             CONF_DEF_VALUE, i:ZOOM_SHOW_X, NULL), 
    215196    CONF_INFO( 59, conf.use_zoom_mf,            CONF_DEF_VALUE, i:0, NULL), 
    216197    CONF_INFO( 60, conf.raw_save_first_only,    CONF_DEF_VALUE, i:0, NULL), 
    217     CONF_INFO( 61, conf.reader_wrap_by_words,   CONF_DEF_VALUE, i:1, NULL), 
     198    //CONF_INFO( 61, conf.reader_wrap_by_words,   CONF_DEF_VALUE, i:1, NULL), 
    218199    CONF_INFO( 62, conf.menu_symbol_enable,     CONF_DEF_VALUE, i:1, NULL), 
    219200    CONF_INFO( 63, conf.alt_mode_button,        CONF_DEF_VALUE, i:KEY_PRINT, conf_change_alt_mode_button), 
     
    223204    CONF_INFO( 67, conf.alt_prevent_shutdown,   CONF_DEF_VALUE, i:ALT_PREVENT_SHUTDOWN_ALT, conf_update_prevent_shutdown), 
    224205    CONF_INFO( 68, conf.show_grid_lines,        CONF_DEF_VALUE, i:0, NULL), 
    225     CONF_INFO( 69, conf.grid_lines_file,        CONF_CHAR_PTR,   ptr:"", conf_change_grid_file), 
     206    //CONF_INFO( 69, conf.grid_lines_file,        CONF_CHAR_PTR,   ptr:"", NULL), 
    226207    CONF_INFO( 70, conf.raw_nr,                 CONF_DEF_VALUE, i:NOISE_REDUCTION_AUTO_CANON, NULL), 
    227     CONF_INFO( 71, conf.grid_force_color,       CONF_DEF_VALUE, i:0, NULL), 
    228     CONF_INFO( 72, conf.grid_color,             CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL), 
     208    //CONF_INFO( 71, conf.grid_force_color,       CONF_DEF_VALUE, i:0, NULL), 
     209    //CONF_INFO( 72, conf.grid_color,             CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL), 
    229210 
    230211    CONF_INFO( 80, conf.dof_subj_dist_as_near_limit,CONF_DEF_VALUE, i:0, NULL), 
     
    287268     
    288269    CONF_INFO(126, conf.clear_bracket,          CONF_DEF_VALUE, i:1, NULL), 
    289     CONF_INFO(127, conf.zebra_multichannel,     CONF_DEF_VALUE, i:0, NULL), 
     270    //CONF_INFO(127, conf.zebra_multichannel,     CONF_DEF_VALUE, i:0, NULL), 
    290271 
    291272    CONF_INFO(128, conf.nd_filter_state,        CONF_DEF_VALUE, i:0, NULL), 
     
    355336    CONF_INFO(187, conf.edge_overlay_enable,    CONF_DEF_VALUE, i:0, NULL), 
    356337    CONF_INFO(188, conf.edge_overlay_thresh,    CONF_DEF_VALUE, i:60, NULL), 
    357     CONF_INFO(189, conf.edge_overlay_color,     CONF_DEF_VALUE, cl:0x66, NULL), 
     338    //CONF_INFO(189, conf.edge_overlay_color,     CONF_DEF_VALUE, cl:0x66, NULL), 
    358339    CONF_INFO(190, conf.synch_enable,           CONF_DEF_VALUE, i:0, NULL), 
    359340    CONF_INFO(191, conf.synch_delay_enable,     CONF_DEF_VALUE, i:0, NULL), 
     
    388369    CONF_INFO(220, conf.temperature_unit,              CONF_DEF_VALUE, i:0, NULL), 
    389370    CONF_INFO(221, conf.clear_zoom_override,         CONF_DEF_VALUE, i:1, NULL),                         
    390     CONF_INFO(222, conf.edge_overlay_play,    CONF_DEF_VALUE, i:0, NULL), 
    391     CONF_INFO(223, conf.edge_overlay_pano,              CONF_DEF_VALUE, i:0, NULL), 
    392     CONF_INFO(224, conf.edge_overlay_zoom,                CONF_DEF_VALUE, i:1, NULL), 
     371    //CONF_INFO(222, conf.edge_overlay_play,    CONF_DEF_VALUE, i:0, NULL), 
     372    //CONF_INFO(223, conf.edge_overlay_pano,              CONF_DEF_VALUE, i:0, NULL), 
     373    //CONF_INFO(224, conf.edge_overlay_zoom,                CONF_DEF_VALUE, i:1, NULL), 
    393374    CONF_INFO(225, conf.raw_cache,              CONF_DEF_VALUE, i:0, NULL), 
    394375    CONF_INFO(226, conf.dng_raw,                CONF_DEF_VALUE, i:0, conf_change_dng), 
     
    407388        CONF_INFO(239, conf.debug_propcase_page,     CONF_DEF_VALUE, i:0, NULL), 
    408389        CONF_INFO(240, conf.debug_misc_vals_show,     CONF_DEF_VALUE, i:0, NULL), 
    409         CONF_INFO(241, conf.edge_overlay_filter,     CONF_DEF_VALUE, i:0, NULL), 
    410         CONF_INFO(242, conf.edge_overlay_show,     CONF_DEF_VALUE, i:0, NULL), 
    411     CONF_INFO(243, conf.edge_overlay_pano_overlap,   CONF_DEF_VALUE, i:30, NULL), 
     390        //CONF_INFO(241, conf.edge_overlay_filter,     CONF_DEF_VALUE, i:0, NULL), 
     391        //CONF_INFO(242, conf.edge_overlay_show,     CONF_DEF_VALUE, i:0, NULL), 
     392    //CONF_INFO(243, conf.edge_overlay_pano_overlap,   CONF_DEF_VALUE, i:30, NULL), 
    412393 
    413394    // Touch screen U/I overrides 
     
    422403        CONF_INFO(248, conf.remote_switch_type,  CONF_DEF_VALUE, i:0, NULL), 
    423404        CONF_INFO(249, conf.remote_control_mode,  CONF_DEF_VALUE, i:0, NULL), 
     405 
     406    // Text Box char map file 
     407    CONF_INFO(248, conf.charmap_file,        CONF_CHAR_PTR,   ptr:"", NULL), 
    424408 
    425409   }; 
     
    437421    case  66: conf_change_menu_rbf_file(); break; 
    438422    case  67: conf_update_prevent_shutdown(); break; 
    439     case  69: conf_change_grid_file(); break; 
    440423    case 101: conf_change_video_bitrate(); break; 
    441424    case 183: conf_change_menu_symbol_rbf_file(); break; 
    442425    case 194: conf_change_script_file(); break; 
     426    case 2: 
    443427    case 226: conf_change_dng(); break; 
    444428    case 235: conf_change_dng_ext(); break; 
     
    490474} 
    491475 
    492 static void conf_change_grid_file() { 
    493     grid_lines_load(conf.grid_lines_file); 
    494 } 
    495  
    496476static void conf_change_video_bitrate() { 
    497477    shooting_video_bitrate_change(conf.video_bitrate); 
     
    500480void conf_change_dng(void){ 
    501481#if DNG_SUPPORT 
    502  if (conf.dng_raw) { 
     482 if (conf.save_raw && conf.dng_raw) { 
    503483        if ( !module_dng_load(LIBDNG_OWNED_BY_RAW) ) 
    504484                return; 
     
    578558 
    579559//------------------------------------------------------------------- 
    580 void conf_load_defaults() { 
     560void config_load_defaults(const ConfInfo *confinfo, int conf_num, void (*info_func)(unsigned short id)) 
     561{ 
    581562    register int i; 
    582563 
    583     for (i=0; i<CONF_NUM; ++i) { 
    584         switch (conf_info[i].type) { 
     564    for (i=0; i<conf_num; ++i) { 
     565        switch (confinfo[i].type) { 
    585566            case CONF_DEF_VALUE: 
    586                 memcpy(conf_info[i].var, &(conf_info[i].i), conf_info[i].size); 
     567                memcpy(confinfo[i].var, &(confinfo[i].i), confinfo[i].size); 
    587568                break; 
    588569            case CONF_INT_PTR: 
     
    590571            case CONF_OSD_POS_PTR: 
    591572            case CONF_CHAR_PTR: 
    592                 memcpy(conf_info[i].var, conf_info[i].ptr, conf_info[i].size); 
     573                memcpy(confinfo[i].var, confinfo[i].ptr, confinfo[i].size); 
    593574                break; 
    594575        } 
    595         conf_info_func(conf_info[i].id); 
    596         //if (conf_info[i].func) { 
    597         //    conf_info[i].func(); 
    598         //} 
    599     } 
     576        if (info_func) info_func(confinfo[i].id); 
     577    } 
     578} 
     579 
     580void conf_load_defaults() 
     581{ 
     582    config_load_defaults(&conf_info[0], CONF_NUM, conf_info_func); 
    600583} 
    601584 
     
    609592} ConfInfoSave; 
    610593 
    611 void conf_save() { 
     594void config_save(const ConfInfo *conf_info, char *filename, int conf_num) 
     595{ 
    612596    static const long t=CONF_MAGICK_VALUE; 
    613597    register int i; 
    614     int fd; 
    615     char *buf = umalloc(sizeof(t) + CONF_NUM*sizeof(ConfInfoSave) + sizeof(conf)); 
    616     char *p=buf; 
    617  
    618     fd = open(CONF_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0777);  
    619     if (fd>=0){ 
     598     
     599    int size = sizeof(t) + conf_num * sizeof(ConfInfoSave); 
     600    for (i=0; i<conf_num; i++) size += conf_info[i].size; 
     601 
     602    char *buf = umalloc(size); 
     603    char *p = buf; 
     604 
     605    int fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0777);  
     606    if (fd >= 0) 
     607    { 
    620608        memcpy(p, &t, sizeof(t)); 
    621         p+=sizeof(t); 
    622         for (i=0; i<CONF_NUM; ++i) { 
     609        p += sizeof(t); 
     610        for (i=0; i<conf_num; ++i) 
     611        { 
    623612            ((ConfInfoSave*)p)->id   = conf_info[i].id; 
    624613            ((ConfInfoSave*)p)->size = conf_info[i].size; 
    625614            p += sizeof(ConfInfoSave); 
    626615            memcpy(p, conf_info[i].var, conf_info[i].size); 
     616            // Clear out unused space after string config item value 
     617            if ((conf_info[i].size == CONF_STR_LEN) && (strlen(conf_info[i].var) < CONF_STR_LEN)) 
     618                memset(p+strlen(conf_info[i].var), 0, CONF_STR_LEN-strlen(conf_info[i].var)); 
    627619            p += conf_info[i].size; 
    628620        } 
     
    634626} 
    635627 
    636 //------------------------------------------------------------------- 
    637 void conf_restore() { 
     628void conf_save() 
     629{ 
     630    config_save(&conf_info[0], CONF_FILE, CONF_NUM); 
     631} 
     632 
     633//------------------------------------------------------------------- 
     634void config_restore(const ConfInfo *confinfo, char *filename, int conf_num, void (*init_defaults)(), void (*info_func)(unsigned short id)) 
     635{ 
    638636    int fd, rcnt, i; 
    639637    unsigned short id, size; 
    640638    char *buf; 
    641     int offs; 
     639    int offs, old_ver; 
    642640    struct stat st; 
    643641 
    644     conf_init_defaults(); 
    645  
    646     conf_load_defaults(); 
    647  
    648     if( stat(CONF_FILE,&st) != 0 || st.st_size < sizeof(int)) 
     642    if (init_defaults) init_defaults(); 
     643    config_load_defaults(confinfo, conf_num, info_func); 
     644 
     645    if( stat(filename,&st) != 0 || st.st_size < sizeof(int)) 
    649646        return; 
    650647 
     
    652649        return; 
    653650 
    654     fd = open(CONF_FILE, O_RDONLY, 0777);  
     651    fd = open(filename, O_RDONLY, 0777);  
    655652    if( fd < 0 ) { 
    656653        ufree(buf); 
     
    665662        return; 
    666663    } 
     664 
    667665    offs=sizeof(int); 
    668666    while (1) { 
     
    677675        offs += sizeof(short); 
    678676 
    679         for (i=0; i<CONF_NUM; ++i) { 
    680             if (conf_info[i].id==id && conf_info[i].size==size) { 
     677        for (i=0; i<conf_num; ++i) { 
     678            if (confinfo[i].id==id && confinfo[i].size==size) { 
    681679                if (offs + size <= rcnt) { 
    682                    memcpy(conf_info[i].var, buf+offs, size); 
    683                    conf_info_func(conf_info[i].id); 
    684                    //if (conf_info[i].func) { 
    685                    //    conf_info[i].func(); 
    686                    //} 
     680                   memcpy(confinfo[i].var, buf+offs, size); 
     681                   if (info_func) info_func(confinfo[i].id); 
    687682                } 
    688683                offs += size; 
     
    690685            } 
    691686        } 
    692         if (i == CONF_NUM) { // unknown id, just skip data 
     687        if (i == conf_num) { // unknown id, just skip data 
    693688            offs += size; 
    694689        } 
     
    697692    // clear any "clear on restart" values 
    698693    clear_values(); 
     694} 
     695 
     696void conf_restore() 
     697{ 
     698    config_restore(&conf_info[0], CONF_FILE, CONF_NUM, conf_init_defaults, conf_info_func); 
    699699} 
    700700 
     
    814814    } 
    815815    if( ret!=CONF_EMPTY ) { 
    816      //   if (conf_info[i].func) { 
    817      //      conf_info[i].func(); 
    818      //   } 
    819816        conf_save(); 
    820817    } 
    821818    return ret; 
    822819} 
     820 
     821//------------------------------------------------------------------- 
    823822// Common code extracted from raw.c (raw_savefile) and gui_osd.c (gui_osd_draw_raw_info) 
    824823// returns 0 if RAW save is disabled due to mode settings, etc, return 1 if RAW save OK 
  • trunk/core/curves.c

    r1527 r1569  
    33#include "stdlib.h" 
    44#include "raw.h" 
    5  
    6 //#ifdef OPT_CURVES 
    7 #if 1 
    8  
     5#include "gui_menu.h" 
     6#include "gui_lang.h" 
     7 
     8#include "modules.h" 
    99#include "module_exportlist.h" 
    1010#include "curves.h" 
    11  
    12 char *conf_curve_file; 
    13 int *conf_curve_enable; 
    1411 
    1512/* 
     
    106103 
    107104void curve_init_mode() { 
    108         switch(*conf_curve_enable) { 
     105        switch(conf.curve_enable) { 
    109106                case 1: // custom - ensure alloc and load conf.curve_file 
    110                         curve_load_data(conf_curve_file,CURVE_CUSTOM); 
     107                        curve_load_data(conf.curve_file,CURVE_CUSTOM); 
    111108                break; 
    112109                case 2: // system - ensure alloc and load syscurve 
     
    116113                break; 
    117114                default: 
    118                         *conf_curve_enable = 0; 
     115                        conf.curve_enable = 0; 
    119116                case 0: // disabled - free 
    120117                        curve_free_data(); 
     
    371368        short EVbias = shooting_get_ev_correction1(); 
    372369 
    373         switch(*conf_curve_enable) { 
     370        switch(conf.curve_enable) { 
    374371                case 0: 
    375372                        break; 
     
    385382                case 2: 
    386383                case 3: // +1EV,  +2EV 
    387                         if (current_curve_type == CURVE_SYSTEM) curveL_apply( *conf_curve_enable & 1 ); 
     384                        if (current_curve_type == CURVE_SYSTEM) curveL_apply( conf.curve_enable & 1 ); 
    388385                        break; 
    389386                case 4:         // Auto DR 
     
    401398} 
    402399 
     400 
     401//------------------------------------------------------------------- 
     402const char* gui_conf_curve_enum(int change, int arg) { 
     403    static const char* modes[]={ "None", "Custom", "+1EV", "+2EV", "Auto DR" }; 
     404 
     405    gui_enum_value_change(&conf.curve_enable,change,sizeof(modes)/sizeof(modes[0])); 
     406 
     407        if (change) 
     408                curve_init_mode(); 
     409    return modes[conf.curve_enable]; 
     410} 
     411 
     412static void gui_load_curve_selected(const char *fn) { 
     413        if (fn) { 
     414                // TODO we could sanity check here, but curve_set_type should fail gracefullish 
     415                strcpy(conf.curve_file,fn); 
     416                if (conf.curve_enable == 1) 
     417                        curve_init_mode(); 
     418        } 
     419} 
     420 
     421void gui_load_curve(int arg) { 
     422    module_fselect_init(LANG_STR_SELECT_CURVE_FILE, conf.curve_file, CURVE_DIR, gui_load_curve_selected); 
     423} 
     424 
     425static CMenuItem curve_submenu_items[] = { 
     426    MENU_ITEM(0x5f,LANG_MENU_CURVE_ENABLE,        MENUITEM_ENUM,      gui_conf_curve_enum, 0 ), 
     427    MENU_ITEM(0x35,LANG_MENU_CURVE_LOAD,          MENUITEM_PROC,      gui_load_curve, 0 ), 
     428    MENU_ITEM(0x51,LANG_MENU_BACK,                MENUITEM_UP, 0, 0 ), 
     429    {0} 
     430}; 
     431static CMenu curve_submenu = {0x85,LANG_MENU_CURVE_PARAM_TITLE, NULL, curve_submenu_items }; 
     432 
    403433// =========  MODULE INIT ================= 
    404434 
     
    407437 
    408438struct libcurves_sym libcurves = { 
    409                         MAKE_API_VERSION(1,0),          // apiver: increase major if incomplatible changes made in module,  
     439                        MAKE_API_VERSION(1,0),          // apiver: increase major if incompatible changes made in module,  
    410440                                                                                // increase minor if compatible changes made(including extending this struct) 
    411441                        curve_init_mode, 
     
    421451void* MODULE_EXPORT_LIST[] = { 
    422452        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
    423         /* 1 */ (void*)3, 
     453        /* 1 */ (void*)1, 
    424454                        &libcurves 
    425455                }; 
     
    432462// RETURN VALUE: 1 error, 0 ok 
    433463//--------------------------------------------------------- 
    434 int _module_loader( void** chdk_export_list ) 
     464int _module_loader( unsigned int* chdk_export_list ) 
    435465{ 
    436   if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     466  if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    437467     return 1; 
    438468 
    439469  if ( !API_VERSION_MATCH_REQUIREMENT( camera_sensor.api_version, 1, 0 ) ) 
    440470         return 1; 
    441  
    442   // Safe bind of conf. 
    443   tConfigVal configVal; 
    444   CONF_BIND_STR(185, conf_curve_file); 
    445   CONF_BIND_INT(186, conf_curve_enable ); 
     471  if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 
     472         return 1; 
    446473 
    447474  // Startup initialize 
     
    466493 
    467494 
     495//--------------------------------------------------------- 
     496// PURPOSE: Default action for simple modules (direct run) 
     497// NOTE: Please comment this function if no default action and this library module 
     498//--------------------------------------------------------- 
     499int _module_run(int moduleidx, int argn, int* arguments) 
     500{ 
     501  module_idx=moduleidx; 
     502 
     503  gui_activate_sub_menu(&curve_submenu, module_idx); 
     504 
     505  return 0; 
     506} 
     507 
     508 
    468509/******************** Module Information structure ******************/ 
    469510 
     
    481522 
    482523/*************** END OF AUXILARY PART *******************/ 
    483  
    484  
    485 #endif 
  • trunk/core/curves.h

    r1527 r1569  
    1616        // This section is for CHDK core 
    1717        extern struct libcurves_sym* libcurves; 
     18    extern struct libcurves_sym* module_curves_load();          // 0fail, addr-ok 
    1819#else 
    1920        // This section is for module 
  • trunk/core/dng.c

    r1558 r1569  
    735735 
    736736struct libdng_sym libdng = { 
    737                         MAKE_API_VERSION(1,0),          // apiver: increase major if incomplatible changes made in module,  
     737                        MAKE_API_VERSION(1,0),          // apiver: increase major if incompatible changes made in module,  
    738738                                                                                // increase minor if compatible changes made(including extending this struct) 
    739739 
     
    752752void* MODULE_EXPORT_LIST[] = { 
    753753        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
    754         /* 1 */ (void*)3, 
     754        /* 1 */ (void*)1, 
    755755 
    756756                        &libdng 
     
    758758 
    759759//-------------------------------------------- 
    760 int _module_loader( void** chdk_export_list ) 
     760int _module_loader( unsigned int* chdk_export_list ) 
    761761{ 
    762   if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     762  if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    763763     return 1; 
    764764 
  • trunk/core/dng.h

    r1527 r1569  
    1919// Defines of exported to chdk symbols 
    2020#ifdef THIS_IS_CHDK_CORE 
     21    // This section is for CHDK core 
    2122 
    22         // This section is for CHDK core 
     23    // values of semaphore 
     24    #define LIBDNG_OWNED_BY_RAW                         0x1 
     25    #define LIBDNG_OWNED_BY_CONVERT             0x2 
     26    #define LIBDNG_OWNED_BY_CREATEBADPIXEL      0x4 
     27 
    2328        extern struct libdng_sym* libdng; 
     29    extern struct libdng_sym* module_dng_load(int owner);               // 0fail, addr-ok 
     30    extern void module_dng_unload(int owner); 
     31 
    2432#else 
    2533         
     
    3341        extern void write_dng(int fd, char* rawadr, char* altrawadr, unsigned long uncachedbit); 
    3442 
    35 extern void unload_bad_pixels_list_b(void); 
     43    extern void unload_bad_pixels_list_b(void); 
    3644 
    3745#endif 
    3846 
     47extern int module_convert_dng_to_chdk_raw(char* fn);            // Return: 0-fail, 1-ok 
     48 
    3949#endif 
  • trunk/core/edgeoverlay.c

    r1527 r1569  
    66#include "stdlib.h" 
    77#include "gui_draw.h" 
     8#include "gui_menu.h" 
     9#include "gui_lang.h" 
    810#include "bitvector.h" 
     11 
     12#include "modules.h" 
    913#include "module_exportlist.h" 
    1014 
     15//------------------------------------------------------------------- 
     16 
     17typedef struct 
     18{ 
     19    color edge_overlay_color; 
     20    int edge_overlay_filter; 
     21    int edge_overlay_zoom;    // shall zoom be set when *edg file is loaded? 
     22    int edge_overlay_pano;    // whether a full press changes back to live mode 
     23    int edge_overlay_pano_overlap;    // overlap in % in pano mode 
     24    int edge_overlay_show;    // whether to show overlay even when no button is pressed 
     25    int edge_overlay_play;    // whether edge overlay is switched on also for play mode 
     26} EdgeConf; 
     27 
     28EdgeConf econf; 
     29 
     30static ConfInfo conf_info[] = { 
     31    CONF_INFO( 1, econf.edge_overlay_color,     CONF_DEF_VALUE, cl:0, NULL), 
     32    CONF_INFO( 2, econf.edge_overlay_play,    CONF_DEF_VALUE, i:0, NULL), 
     33    CONF_INFO( 3, econf.edge_overlay_pano,              CONF_DEF_VALUE, i:0, NULL), 
     34    CONF_INFO( 4, econf.edge_overlay_zoom,                CONF_DEF_VALUE, i:1, NULL), 
     35        CONF_INFO( 5, econf.edge_overlay_filter,     CONF_DEF_VALUE, i:0, NULL), 
     36        CONF_INFO( 6, econf.edge_overlay_show,     CONF_DEF_VALUE, i:0, NULL), 
     37    CONF_INFO( 7, econf.edge_overlay_pano_overlap,   CONF_DEF_VALUE, i:30, NULL), 
     38}; 
     39 
     40//------------------------------------------------------------------- 
    1141 
    1242// the way we save edge overlays on their own... 
     
    1444#define EDGE_FILE_FORMAT EDGE_FILE_PREFIX "%04d.edg" 
    1545#define EDGE_SLICES     2 
    16  
    17 int* conf_edge_overlay_filter; 
    18 color* conf_osd_color; 
    19 int* conf_edge_overlay_zoom; 
    20 int* conf_edge_overlay_thresh; 
    21 color* conf_edge_overlay_color; 
    22 int* conf_edge_overlay_pano; 
    23 int* conf_edge_overlay_pano_overlap; 
    24 int* conf_edge_overlay_show; 
    25 int* conf_edge_overlay_play; 
    2646 
    2747typedef enum _edge_fsm_state 
     
    6181static void ensure_allocate_imagebuffer() 
    6282{ 
    63     if(edgebuf == NULL) 
     83    if (edgebuf == NULL) 
    6484    { 
    6585        edgebuf = bv_create(viewport_height * viewport_width, 1); 
     
    6787            memset(edgebuf->ptr, 0, edgebuf->ptrLen); 
    6888    } 
    69     if (*conf_edge_overlay_filter && (smbuf == NULL)) 
     89    if (econf.edge_overlay_filter && (smbuf == NULL)) 
    7090    { 
    7191        smbuf = (unsigned char*)malloc(viewport_byte_width*3); 
     
    7595        { 
    7696            // Disable filtering if we do not have enough memory for it 
    77             *conf_edge_overlay_filter = 0; 
     97            econf.edge_overlay_filter = 0; 
    7898        } 
    7999    } 
     
    97117    fsm_state = EDGE_LIVE; 
    98118    slice = 0; 
     119 
     120    // Clean up state saved in core CHDK 
     121    module_save_edge(edgebuf, fsm_state); 
    99122} 
    100123 
     
    146169    if( !is_buffer_ready() ) 
    147170    { 
    148         draw_string(0, 0, "No overlay to save.", *conf_osd_color); 
     171        draw_string(0, 0, "No overlay to save.", conf.osd_color); 
    149172        return; 
    150173    } 
     
    181204        utime(fn, &t); 
    182205        sprintf(msg, "Saved as %s",fn); 
    183         draw_string(0, 0, msg, *conf_osd_color); 
     206        draw_string(0, 0, msg, conf.osd_color); 
    184207    } 
    185208    safe_closedir(d); 
     
    203226        { 
    204227            fsm_state = EDGE_FROZEN;    // switch to "edge overlay frozen"-mode 
    205             if (*conf_edge_overlay_zoom) 
     228            if (econf.edge_overlay_zoom) 
    206229            { 
    207230                shooting_set_zoom(zoom); 
     
    311334    memset(edgebuf->ptr + slice*compressed_slice, 0, compressed_slice); 
    312335 
    313     if (*conf_edge_overlay_filter) 
     336    if (econf.edge_overlay_filter) 
    314337    { 
    315338        // Prefill smbuf with three lines of avergae-filtered data. 
     
    333356        shutter_fullpress |= kbd_is_key_pressed(KEY_SHOOT_FULL); 
    334357 
    335         if (*conf_edge_overlay_filter) 
     358        if (econf.edge_overlay_filter) 
    336359        { 
    337360            // We need to shift up our smbuf one line, 
     
    385408                conv2 = -conv2; 
    386409 
    387             if (conv1 + conv2 > *conf_edge_overlay_thresh) 
     410            if (conv1 + conv2 > conf.edge_overlay_thresh) 
    388411            { 
    389412                bv_set(edgebuf, (y-viewport_yoffset-camera_screen.edge_hmargin)*viewport_width + xdiv3, 1); 
     
    415438                conv2 = -conv2; 
    416439 
    417             if (conv1 + conv2 > *conf_edge_overlay_thresh) 
     440            if (conv1 + conv2 > conf.edge_overlay_thresh) 
    418441            { 
    419442                bv_set(edgebuf, (y-viewport_yoffset-camera_screen.edge_hmargin)*viewport_width + xdiv3+1, 1); 
     
    429452//  care so much about performance, you can enable it. 
    430453// 
    431 //    if (*conf_edge_overlay_filter) 
     454//    if (econf.edge_overlay_filter) 
    432455//    { 
    433456//        // Here we do basic filtering on the detected edges. 
     
    464487//                            bv_get(edgebuf, (y+1)*viewport_width + (x+1)); 
    465488// 
    466 //                        if (!*conf_edge_overlay_show) 
     489//                        if (!econf.edge_overlay_show) 
    467490//                        { 
    468491//                            if (sum >= 5)    // if we have at least 5 neighboring edges 
     
    492515    int x_off, y_off; 
    493516 
    494     const color cl = *conf_edge_overlay_color; 
     517    const color cl = econf.edge_overlay_color; 
    495518    const int y_slice_min = viewport_yoffset+camera_screen.edge_hmargin+ slice   *slice_height; 
    496519    const int y_slice_max = viewport_yoffset+camera_screen.edge_hmargin+(slice+1)*slice_height; 
     
    523546                    const int aspect_correct_x_off = x_off; 
    524547                    const int bEdge = bv_get(edgebuf, y_edgebuf + x); 
    525                     const int bDraw = bEdge || (draw_get_pixel(aspect_correct_x_off, y_off) == *conf_edge_overlay_color); 
    526                     const color cl = bEdge ? *conf_edge_overlay_color : 0; 
     548                    const int bDraw = bEdge || (draw_get_pixel(aspect_correct_x_off, y_off) == econf.edge_overlay_color); 
     549                    const color cl = bEdge ? econf.edge_overlay_color : 0; 
    527550                    if (bEdge || bDraw) 
    528551                        draw_pixel(aspect_correct_x_off, y_off, cl); 
     
    582605    const int x_max = (viewport_width - 2); 
    583606 
    584     switch(*conf_edge_overlay_pano) 
     607    switch(econf.edge_overlay_pano) 
    585608    { 
    586609    case 0:     // pano off 
     
    589612        break; 
    590613    case 1:     // pano from left to right 
    591         xoffset = -x_max*(100-*conf_edge_overlay_pano_overlap)/100; 
     614        xoffset = -x_max*(100-econf.edge_overlay_pano_overlap)/100; 
    592615        break; 
    593616    case 2:     // pano from top to bottom 
    594         yoffset = -y_max*(100-*conf_edge_overlay_pano_overlap)/100; 
     617        yoffset = -y_max*(100-econf.edge_overlay_pano_overlap)/100; 
    595618        break; 
    596619    case 3:     // pano from right to left 
    597         xoffset = x_max*(100-*conf_edge_overlay_pano_overlap)/100; 
     620        xoffset = x_max*(100-econf.edge_overlay_pano_overlap)/100; 
    598621        break; 
    599622    case 4:     // pano from bottom to top 
    600         yoffset = y_max*(100-*conf_edge_overlay_pano_overlap)/100; 
     623        yoffset = y_max*(100-econf.edge_overlay_pano_overlap)/100; 
    601624        break; 
    602625    case 5:     // free mode 
     
    636659    const int bHalfPress = kbd_is_key_pressed(KEY_SHOOT_HALF); 
    637660    const int bPlayMode = (mode_get() & MODE_MASK) == MODE_PLAY; 
    638     const int bPanoramaMode = (*conf_edge_overlay_pano != 0); 
    639     const int bNeedHalfPress = (*conf_edge_overlay_show != 1); 
    640     const int bDisplayInPlay = (*conf_edge_overlay_play == 1); 
     661    const int bPanoramaMode = (econf.edge_overlay_pano != 0); 
     662    const int bNeedHalfPress = (econf.edge_overlay_show != 1); 
     663    const int bDisplayInPlay = (econf.edge_overlay_play == 1); 
    641664    const int bGuiModeNone = (gui_get_mode() == GUI_MODE_NONE); 
    642665    const int bGuiModeAlt = (gui_get_mode() == GUI_MODE_ALT); 
     
    721744            // calculations. 
    722745            bFullPress |= draw_edge_overlay(); 
    723             draw_string(0, 0, "Frozen", *conf_osd_color); 
     746            draw_string(0, 0, "Frozen", conf.osd_color); 
    724747        } 
    725748 
     
    755778 
    756779 
    757  
     780//------------------------------------------------------------------- 
     781static void gui_load_edge_selected( const char* fn ) { 
     782    if (fn) 
     783                load_edge_overlay(fn); 
     784} 
     785 
     786void gui_menuproc_edge_save(int arg) { 
     787    save_edge_overlay(); 
     788} 
     789 
     790void gui_menuproc_edge_load(int arg) { 
     791    module_fselect_init(LANG_MENU_EDGE_LOAD, EDGE_SAVE_DIR, EDGE_SAVE_DIR, gui_load_edge_selected); 
     792} 
     793 
     794static const char* gui_edge_pano_modes[] = { "Off", "Right", "Down", "Left", "Up", "Free"}; 
     795static CMenuItem edge_overlay_submenu_items[] = { 
     796    MENU_ITEM(0x5c,LANG_MENU_EDGE_OVERLAY_ENABLE,   MENUITEM_BOOL,              &conf.edge_overlay_enable, 0 ), 
     797    MENU_ITEM(0x5c,LANG_MENU_EDGE_FILTER,           MENUITEM_BOOL,              &econf.edge_overlay_filter, 0 ), 
     798    MENU_ENUM2(0x5f,LANG_MENU_EDGE_PANO,            &econf.edge_overlay_pano,    gui_edge_pano_modes ), 
     799    MENU_ITEM(0x5e,LANG_MENU_EDGE_PANO_OVERLAP,     MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &econf.edge_overlay_pano_overlap, MENU_MINMAX(0, 100) ), 
     800    MENU_ITEM(0x5c,LANG_MENU_EDGE_SHOW,             MENUITEM_BOOL,              &econf.edge_overlay_show, 0 ), 
     801    MENU_ITEM(0x5e,LANG_MENU_EDGE_OVERLAY_TRESH,    MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.edge_overlay_thresh, MENU_MINMAX(0, 255) ), 
     802    MENU_ITEM(0x65,LANG_MENU_EDGE_OVERLAY_COLOR,    MENUITEM_COLOR_FG,          &econf.edge_overlay_color, 0 ), 
     803    MENU_ITEM(0x5c,LANG_MENU_EDGE_PLAY,                     MENUITEM_BOOL,                      &econf.edge_overlay_play, 0 ), //does not work on cams like s-series, which dont have a real "hardware" play/rec switch, need a workaround, probably another button 
     804    MENU_ITEM(0x33,LANG_MENU_EDGE_SAVE,                     MENUITEM_PROC,                      gui_menuproc_edge_save, 0 ), 
     805    MENU_ITEM(0x5c,LANG_MENU_EDGE_ZOOM,             MENUITEM_BOOL,              &econf.edge_overlay_zoom, 0 ), 
     806    MENU_ITEM(0x33,LANG_MENU_EDGE_LOAD,                     MENUITEM_PROC,                      gui_menuproc_edge_load, 0 ), 
     807    MENU_ITEM(0x51,LANG_MENU_BACK,                  MENUITEM_UP, 0, 0 ), 
     808    {0} 
     809}; 
     810static CMenu edge_overlay_submenu = {0x7f,LANG_MENU_EDGE_OVERLAY_TITLE, NULL, edge_overlay_submenu_items }; 
    758811 
    759812 
     
    768821 
    769822struct libedgeovr_sym libedgeovr = { 
    770                         MAKE_API_VERSION(1,0),          // apiver: increase major if incomplatible changes made in module,  
     823                        MAKE_API_VERSION(1,0),          // apiver: increase major if incompatible changes made in module,  
    771824                                                                                // increase minor if compatible changes made(including extending this struct) 
    772825 
    773826                        edge_overlay, 
    774                         save_edge_overlay, 
    775                         load_edge_overlay 
    776827                }; 
    777828 
     
    779830void* MODULE_EXPORT_LIST[] = { 
    780831        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
    781         /* 1 */ (void*)3, 
     832        /* 1 */ (void*)1, 
    782833 
    783834                        &libedgeovr 
     
    791842// RETURN VALUE: 1 error, 0 ok 
    792843//--------------------------------------------------------- 
    793 int _module_loader( void** chdk_export_list ) 
    794 { 
    795   if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     844int _module_loader( unsigned int* chdk_export_list ) 
     845{ 
     846  if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    796847     return 1; 
    797848 
    798849  if ( !API_VERSION_MATCH_REQUIREMENT( camera_sensor.api_version, 1, 0 ) ) 
    799850         return 1; 
    800  
    801  
    802   tConfigVal configVal; 
    803   CONF_BIND_INT(188, conf_edge_overlay_thresh); 
    804   CONF_BIND_COLOR(189, conf_edge_overlay_color); 
    805   CONF_BIND_INT(222, conf_edge_overlay_play); 
    806   CONF_BIND_INT(223, conf_edge_overlay_pano); 
    807   CONF_BIND_INT(224, conf_edge_overlay_zoom); 
    808   CONF_BIND_INT(241, conf_edge_overlay_filter); 
    809   CONF_BIND_INT(242, conf_edge_overlay_show); 
    810   CONF_BIND_INT(243, conf_edge_overlay_pano_overlap); 
    811   CONF_BIND_COLOR( 28, conf_osd_color); 
     851  if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 
     852         return 1; 
     853 
     854  conf_info[0].cl = MAKE_COLOR(0, COLOR_BLUE); 
     855  config_restore(&conf_info[0], "A/CHDK/MODULES/CFG/edgeovr.cfg", sizeof(conf_info)/sizeof(conf_info[0]), 0, 0); 
     856 
     857  module_restore_edge((void**)&edgebuf, (int*)&fsm_state); 
    812858 
    813859  return 0; 
    814860} 
    815  
    816861 
    817862 
     
    822867int _module_unloader() 
    823868{ 
    824         // This could be happens only if on-load mistake 
    825         // CHDK never unload this library (but load only if needed) 
    826         // Reason: edve_overlay allocate different bufs which should be kept 
    827         //              because even if we turn off edgeovr we could turn on back and 
    828         //              should get same content. 
     869    // Save state info 
     870    module_save_edge(edgebuf, fsm_state); 
     871 
     872    // Module can be unloaded when menu exits 
     873    // Edge overlay state is store in core CHDK and will 
     874    // be restored when module reloads 
     875    config_save(&conf_info[0], "A/CHDK/MODULES/CFG/edgeovr.cfg", sizeof(conf_info)/sizeof(conf_info[0])); 
     876 
     877    // Free filter buffer 
     878    if (smbuf != NULL) 
     879    { 
     880        free(smbuf); 
     881        smbuf = NULL; 
     882    } 
     883 
     884    return 0; 
     885} 
     886 
     887 
     888//--------------------------------------------------------- 
     889// PURPOSE: Default action for simple modules (direct run) 
     890// NOTE: Please comment this function if no default action and this library module 
     891//--------------------------------------------------------- 
     892int _module_run(int moduleidx, int argn, int* arguments) 
     893{ 
     894  module_idx=moduleidx; 
     895 
     896  gui_activate_sub_menu(&edge_overlay_submenu, module_idx); 
     897 
    829898  return 0; 
    830899} 
     
    838907                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
    839908                                                                        MODULEINFO_FLAG_SYSTEM,         // flag 
    840                                                                         (int32_t)"Edge Overalay (dll)",// Module name 
     909                                                                        (int32_t)"Edge Overlay (dll)",// Module name 
    841910                                                                        1, 0,                                           // Module version 
    842911                                                                        (int32_t)"Implementation one of core modes" 
  • trunk/core/edgeoverlay.h

    r1527 r1569  
    1212        int  version; 
    1313        void (*edge_overlay)(); 
    14         void (*save_edge_overlay)(void); 
    15         void (*load_edge_overlay)( const char* ); 
    1614}; 
    17  
    1815 
    1916// Defines of exported to chdk symbols 
     
    2118        // This section is for CHDK core 
    2219        extern struct libedgeovr_sym* libedgeovr; 
     20    extern struct libedgeovr_sym* module_edgeovr_load();        // 0fail, addr-ok 
    2321#else 
    2422        // This section is for module 
    25 void edge_overlay(); 
    26 void save_edge_overlay(void); 
    27 void load_edge_overlay( const char* ); 
     23    extern void edge_overlay(); 
    2824#endif 
    2925 
     26extern void module_restore_edge(void **buf, int *state); 
     27extern void module_save_edge(void* buf, int state); 
     28 
    3029#endif 
  • trunk/core/gui.c

    r1568 r1569  
    2323#include "gui_space.h" 
    2424#include "gui_osd.h" 
    25 #ifdef OPT_TEXTREADER 
    26         #include "gui_read.h" 
    27 #endif 
    28 #include "gui_grid.h" 
    2925#include "histogram.h" 
    3026#include "motion_detector.h" 
    3127#include "raw.h" 
    3228#include "dng.h" 
    33 #ifdef OPT_CURVES 
    34         #include "curves.h" 
    35 #endif 
    36 #ifdef OPT_EDGEOVERLAY 
    37         #include "modules.h" 
    38 #endif 
     29#include "modules.h" 
    3930#ifdef OPT_SCRIPTING 
    4031    #include "script.h" 
     
    152143static void gui_show_build_info(int arg); 
    153144static void gui_show_memory_info(int arg); 
    154 void    gui_modules_menu_load(); 
     145//void  gui_modules_menu_load(); 
    155146 
    156147#ifdef OPT_DEBUGGING 
     
    161152#endif 
    162153static void gui_draw_fselect(int arg); 
    163 #ifdef OPT_TEXTREADER 
    164 static void gui_draw_read(int arg); 
    165 static void gui_draw_read_last(int arg); 
    166 #endif 
    167154static void gui_draw_load_menu_rbf(int arg); 
    168155static void gui_draw_load_symbol_rbf(int arg);          //AKA 
    169 #ifdef OPT_TEXTREADER 
    170         static void gui_draw_load_rbf(int arg); 
    171 #endif 
    172156#ifdef OPT_CALENDAR 
    173157static void gui_draw_calendar(int arg); 
    174158#endif 
     159static void gui_load_charmap(int arg); 
    175160static void gui_draw_load_lang(int arg); 
    176161static void gui_menuproc_mkbootdisk(int arg); 
     
    179164#endif 
    180165static void gui_menuproc_reset(int arg); 
    181 static void gui_grid_lines_load(int arg); 
    182166static void gui_raw_develop(int arg); 
    183167static void gui_menuproc_swap_partitions(int arg); 
    184168static void gui_menuproc_reset_files(int arg); 
    185 #ifdef OPT_CURVES 
    186         static void gui_load_curve_selected(const char *fn); 
    187         static void gui_load_curve(int arg); 
    188 #endif 
    189169static const char* gui_histo_mode_enum(int change, int arg); 
    190170static const char* gui_histo_layout_enum(int change, int arg); 
     
    213193static const char* gui_bad_pixel_enum(int change, int arg); 
    214194static const char* gui_video_af_key_enum(int change, int arg); 
    215 #ifdef OPT_CURVES 
    216         static const char* gui_conf_curve_enum(int change, int arg); 
    217 #endif 
    218  
    219 #ifdef OPT_EDGEOVERLAY 
    220 static void gui_menuproc_edge_save(int arg); 
    221 static void gui_menuproc_edge_load(int arg); 
    222 #endif 
    223195 
    224196#ifdef OPT_SCRIPTING 
     
    238210static void cb_space_mb(); 
    239211static void cb_battery_menu_change(unsigned int item); 
    240 static void cb_zebra_restore_screen(); 
    241 static void cb_zebra_restore_osd(); 
    242212#if DNG_SUPPORT 
    243213static void cb_change_dng(); 
     
    328298 
    329299 
    330 #ifdef OPT_TEXTREADER 
    331 static const char* gui_reader_codepage_cps[] = { "Win1251", "DOS"}; 
    332 static CMenuItem reader_submenu_items[] = { 
    333     MENU_ITEM(0x35,LANG_MENU_READ_OPEN_NEW,           MENUITEM_PROC,    gui_draw_read, 0 ), 
    334     MENU_ITEM(0x35,LANG_MENU_READ_OPEN_LAST,          MENUITEM_PROC,    gui_draw_read_last, 0 ), 
    335     MENU_ITEM(0x35,LANG_MENU_READ_SELECT_FONT,        MENUITEM_PROC,    gui_draw_load_rbf, 0 ), 
    336     MENU_ENUM2(0x5f,LANG_MENU_READ_CODEPAGE,          &conf.reader_codepage, gui_reader_codepage_cps ), 
    337     MENU_ITEM(0x5c,LANG_MENU_READ_WORD_WRAP,          MENUITEM_BOOL,    &conf.reader_wrap_by_words, 0 ), 
    338     MENU_ITEM(0x5c,LANG_MENU_READ_AUTOSCROLL,         MENUITEM_BOOL,    &conf.reader_autoscroll, 0 ), 
    339     MENU_ITEM(0x5f,LANG_MENU_READ_AUTOSCROLL_DELAY,   MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.reader_autoscroll_delay, MENU_MINMAX(0, 60) ), 
    340     MENU_ITEM(0x51,LANG_MENU_BACK,                    MENUITEM_UP, 0, 0 ), 
    341     {0} 
    342 }; 
    343 static CMenu reader_submenu = {0x37,LANG_MENU_READ_TITLE, NULL, reader_submenu_items }; 
    344 #endif 
    345  
    346300#ifdef OPT_DEBUGGING 
    347301static const char* gui_debug_shortcut_modes[] = { "None", "DmpRAM", "Page", "CmpProps"}; 
     
    352306    MENU_ITEM(0x2a,LANG_MENU_DEBUG_TASKLIST_START,    MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,   &debug_tasklist_start, MENU_MINMAX(0, 63) ), 
    353307    MENU_ITEM(0x5c,LANG_MENU_DEBUG_SHOW_MISC_VALS,    MENUITEM_BOOL,          &conf.debug_misc_vals_show, 0 ), 
     308    MENU_ITEM(0x2a,LANG_MENU_DEBUG_MEMORY_BROWSER,    MENUITEM_PROC,          gui_menu_run_fltmodule, "memview.flt" ), 
     309    MENU_ITEM(0x2a,LANG_MENU_DEBUG_BENCHMARK,         MENUITEM_PROC,          gui_menu_run_fltmodule, "benchm.flt" ), 
    354310    MENU_ENUM2(0x5c,LANG_MENU_DEBUG_SHORTCUT_ACTION,  &conf.debug_shortcut_action, gui_debug_shortcut_modes ), 
    355311    MENU_ITEM(0x5c,LANG_MENU_RAW_TIMER,               MENUITEM_BOOL,          &conf.raw_timer, 0 ), 
     
    370326static CMenuItem misc_submenu_items[] = { 
    371327    MENU_ITEM(0x35,LANG_MENU_MISC_FILE_BROWSER,       MENUITEM_PROC,    gui_draw_fselect, 0 ), 
    372     MENU_ITEM(0x65,(int)"Modules",                        MENUITEM_TEXT,    0, 0 ), 
     328    MENU_ITEM(0x80,(int)"Module Inspector",           MENUITEM_PROC,    gui_menu_run_fltmodule, "modinsp.flt" ), 
     329#ifdef OPT_CALENDAR 
     330    MENU_ITEM(0x36,LANG_MENU_MISC_CALENDAR,           MENUITEM_PROC,    gui_menu_run_fltmodule, "calend.flt" ), 
     331#endif 
    373332#ifdef OPT_TEXTREADER 
    374     MENU_ITEM(0x37,LANG_MENU_MISC_TEXT_READER,        MENUITEM_SUBMENU, &reader_submenu, 0 ), 
     333    MENU_ITEM(0x37,LANG_MENU_MISC_TEXT_READER,        MENUITEM_SUBMENU_PROC, gui_menu_run_fltmodule, "txtread.flt" ), 
     334#endif 
     335#if defined (OPT_GAMES) 
     336    MENU_ITEM(0x38,LANG_MENU_MISC_GAMES,              MENUITEM_SUBMENU_PROC, gui_menu_run_fltmodule, "gamemenu.flt" ), 
    375337#endif 
    376338#if CAM_SWIVEL_SCREEN 
     
    386348#endif 
    387349    MENU_ITEM(0x5d,LANG_MENU_MISC_DISABLE_LCD_OFF,    MENUITEM_ENUM,    gui_alt_power_enum, 0 ), 
     350    MENU_ITEM(0x65,LANG_MENU_MISC_PALETTE,            MENUITEM_PROC,    gui_menu_run_fltmodule, "palette.flt" ), 
    388351    MENU_ITEM(0x80,LANG_MENU_MISC_BUILD_INFO,         MENUITEM_PROC,    gui_show_build_info, 0 ), 
    389352    MENU_ITEM(0x80,LANG_MENU_MISC_MEMORY_INFO,        MENUITEM_PROC,    gui_show_memory_info, 0 ), 
     
    620583static CMenu operation_submenu = {0x21,LANG_MENU_OPERATION_PARAM_TITLE, NULL, operation_submenu_items }; 
    621584 
    622 #ifdef OPT_EDGEOVERLAY 
    623 static const char* gui_edge_pano_modes[] = { "Off", "Right", "Down", "Left", "Up", "Free"}; 
    624 static CMenuItem edge_overlay_submenu_items[] = { 
    625     MENU_ITEM(0x5c,LANG_MENU_EDGE_OVERLAY_ENABLE,     MENUITEM_BOOL,          &conf.edge_overlay_enable, 0 ), 
    626     MENU_ITEM(0x5c,LANG_MENU_EDGE_FILTER,     MENUITEM_BOOL,          &conf.edge_overlay_filter, 0 ), 
    627     MENU_ENUM2(0x5f,LANG_MENU_EDGE_PANO,    &conf.edge_overlay_pano, gui_edge_pano_modes ), 
    628     MENU_ITEM(0x5e,LANG_MENU_EDGE_PANO_OVERLAP,   MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.edge_overlay_pano_overlap, MENU_MINMAX(0, 100) ), 
    629     MENU_ITEM(0x5c,LANG_MENU_EDGE_SHOW,     MENUITEM_BOOL,          &conf.edge_overlay_show, 0 ), 
    630     MENU_ITEM(0x5e,LANG_MENU_EDGE_OVERLAY_TRESH,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.edge_overlay_thresh, MENU_MINMAX(0, 255) ), 
    631     MENU_ITEM(0x65,LANG_MENU_EDGE_OVERLAY_COLOR,      MENUITEM_COLOR_FG,      &conf.edge_overlay_color, 0 ), 
    632     MENU_ITEM(0x5c,LANG_MENU_EDGE_PLAY,                 MENUITEM_BOOL,          &conf.edge_overlay_play, 0 ), //does not work on cams like s-series, which dont have a real "hardware" play/rec switch, need a workaround, probably another button 
    633     MENU_ITEM(0x33,LANG_MENU_EDGE_SAVE,                 MENUITEM_PROC,          gui_menuproc_edge_save, 0 ), 
    634     MENU_ITEM(0x5c,LANG_MENU_EDGE_ZOOM,     MENUITEM_BOOL,          &conf.edge_overlay_zoom, 0 ), 
    635     MENU_ITEM(0x33,LANG_MENU_EDGE_LOAD,                 MENUITEM_PROC,          gui_menuproc_edge_load, 0 ), 
    636     MENU_ITEM(0x51,LANG_MENU_BACK,                    MENUITEM_UP, 0, 0 ), 
    637     {0} 
    638 }; 
    639 static CMenu edge_overlay_submenu = {0x7f,LANG_MENU_EDGE_OVERLAY_TITLE, NULL, edge_overlay_submenu_items }; 
    640 #endif 
    641  
    642 static CMenuItem grid_submenu_items[] = { 
    643     MENU_ITEM(0x2f,LANG_MENU_SHOW_GRID,               MENUITEM_BOOL,            &conf.show_grid_lines, 0 ), 
    644     MENU_ITEM(0x35,LANG_MENU_GRID_LOAD,               MENUITEM_PROC,            gui_grid_lines_load, 0 ), 
    645     MENU_ITEM(0x0,LANG_MENU_GRID_CURRENT,            MENUITEM_SEPARATOR, 0, 0 ), 
    646     MENU_ITEM(0x0,(int)grid_title,                   MENUITEM_TEXT, 0, 0 ), 
    647     MENU_ITEM(0x0,(int)"",                           MENUITEM_SEPARATOR, 0, 0 ), 
    648     MENU_ITEM(0x5c,LANG_MENU_GRID_FORCE_COLOR,        MENUITEM_BOOL,          &conf.grid_force_color, 0 ), 
    649     MENU_ITEM(0x65,LANG_MENU_GRID_COLOR_LINE,         MENUITEM_COLOR_FG,      &conf.grid_color, 0 ), 
    650     MENU_ITEM(0x65,LANG_MENU_GRID_COLOR_FILL,         MENUITEM_COLOR_BG,      &conf.grid_color, 0 ), 
    651     MENU_ITEM(0x51,LANG_MENU_BACK,                    MENUITEM_UP, 0, 0 ), 
    652     {0} 
    653 }; 
    654 static CMenu grid_submenu = {0x2f,LANG_MENU_GRID_TITLE, NULL, grid_submenu_items }; 
    655  
    656585static CMenuItem visual_submenu_items[] = { 
    657586    MENU_ITEM(0x35,LANG_MENU_VIS_LANG,                MENUITEM_PROC,      gui_draw_load_lang, 0 ), 
     
    659588    MENU_ITEM(0x35,LANG_MENU_VIS_MENU_FONT,           MENUITEM_PROC,      gui_draw_load_menu_rbf, 0 ), 
    660589    MENU_ITEM(0x35,LANG_MENU_VIS_MENU_SYMBOL_FONT,    MENUITEM_PROC,      gui_draw_load_symbol_rbf, 0 ), 
     590    MENU_ITEM(0x35,LANG_MENU_VIS_CHARMAP,             MENUITEM_PROC,      gui_load_charmap, 0 ), 
    661591    MENU_ITEM(0x80,LANG_MENU_RESET_FILES                 ,         MENUITEM_PROC,          gui_menuproc_reset_files, 0 ), 
    662592    MENU_ITEM(0x0,LANG_MENU_VIS_COLORS,              MENUITEM_SEPARATOR, 0, 0 ), 
     
    669599    MENU_ITEM(0x65,LANG_MENU_VIS_HISTO_BORDER,        MENUITEM_COLOR_FG,  &conf.histo_color2, 0 ), 
    670600    MENU_ITEM(0x65,LANG_MENU_VIS_HISTO_MARKERS,       MENUITEM_COLOR_BG,  &conf.histo_color2, 0 ), 
    671     MENU_ITEM(0x65,LANG_MENU_VIS_ZEBRA_UNDER,         MENUITEM_COLOR_BG,  &conf.zebra_color, 0 ), 
    672     MENU_ITEM(0x65,LANG_MENU_VIS_ZEBRA_OVER,          MENUITEM_COLOR_FG,  &conf.zebra_color, 0 ), 
     601    //MENU_ITEM(0x65,LANG_MENU_VIS_ZEBRA_UNDER,         MENUITEM_COLOR_BG,  &conf.zebra_color, 0 ),         // moved to zebra menu 
     602    //MENU_ITEM(0x65,LANG_MENU_VIS_ZEBRA_OVER,          MENUITEM_COLOR_FG,  &conf.zebra_color, 0 ),         // moved to zebra menu 
    673603    MENU_ITEM(0x65,LANG_MENU_VIS_BATT_ICON,           MENUITEM_COLOR_FG,  &conf.batt_icon_color, 0 ), 
    674604    MENU_ITEM(0x65,LANG_MENU_VIS_SPACE_ICON,          MENUITEM_COLOR_FG,  &conf.space_color, 0 ), 
     
    682612    MENU_ITEM(0x65,LANG_MENU_VIS_MENU_SYMBOL_TEXT,    MENUITEM_COLOR_FG,  &conf.menu_symbol_color, 0 ), 
    683613    MENU_ITEM(0x65,LANG_MENU_VIS_MENU_SYMBOL_BKG,     MENUITEM_COLOR_BG,  &conf.menu_symbol_color, 0 ), 
    684     MENU_ITEM(0x65,LANG_MENU_VIS_READER_TEXT,         MENUITEM_COLOR_FG,  &conf.reader_color, 0 ), 
    685     MENU_ITEM(0x65,LANG_MENU_VIS_READER_BKG,          MENUITEM_COLOR_BG,  &conf.reader_color, 0 ), 
     614    //MENU_ITEM(0x65,LANG_MENU_VIS_READER_TEXT,         MENUITEM_COLOR_FG,  &conf.reader_color, 0 ),        // moved to text reader menu 
     615    //MENU_ITEM(0x65,LANG_MENU_VIS_READER_BKG,          MENUITEM_COLOR_BG,  &conf.reader_color, 0 ),        // moved to text reader menu 
    686616    MENU_ITEM(0x65,LANG_MENU_VIS_OSD_OVERRIDE,         MENUITEM_COLOR_FG,  &conf.osd_color_override, 0 ), 
    687617    MENU_ITEM(0x65,LANG_MENU_VIS_OSD_OVERRIDE_BKG,     MENUITEM_COLOR_BG,  &conf.osd_color_override, 0 ), 
     
    742672    MENU_ENUM2(0x71,LANG_MENU_USB_SHOW_INFO,         &conf.usb_info_enable, gui_show_usb_info_modes ), 
    743673    MENU_ITEM(0x72,LANG_MENU_OSD_LAYOUT_EDITOR,       MENUITEM_PROC,      gui_draw_osd_le, 0 ), 
    744     MENU_ITEM(0x2f,LANG_MENU_OSD_GRID_PARAMS,         MENUITEM_SUBMENU,   &grid_submenu, 0 ), 
     674    MENU_ITEM(0x2f,LANG_MENU_OSD_GRID_PARAMS,         MENUITEM_SUBMENU_PROC, gui_menu_run_fltmodule, "grids.flt" ), 
    745675    MENU_ITEM(0x22,LANG_MENU_OSD_VALUES,                MENUITEM_SUBMENU,   &values_submenu, 0 ), 
    746676    MENU_ITEM(0x31,LANG_MENU_OSD_DOF_CALC,            MENUITEM_SUBMENU,   &dof_submenu, 0 ), 
     
    799729static const char* gui_raw_nr_modes[] = { "Auto", "Off", "On"}; 
    800730static CMenuItem raw_submenu_items[] = { 
    801     MENU_ITEM(0x5c,LANG_MENU_RAW_SAVE,                MENUITEM_BOOL,      &conf.save_raw, 0 ), 
     731    MENU_ITEM(0x5c,LANG_MENU_RAW_SAVE,                MENUITEM_BOOL | MENUITEM_ARG_CALLBACK, &conf.save_raw, (int)cb_change_dng ), 
    802732    MENU_ITEM(0x59,LANG_MENU_OSD_RAW_EXCEPTIONS_PARAMS,         MENUITEM_SUBMENU,   &raw_exceptions_submenu, 0 ), 
    803733    MENU_ENUM2(0x5f,LANG_MENU_RAW_NOISE_REDUCTION,    &conf.raw_nr, gui_raw_nr_modes ), 
     
    823753static CMenu raw_submenu = {0x24,LANG_MENU_RAW_TITLE, NULL, raw_submenu_items }; 
    824754 
    825  
    826 static const char* gui_zebra_mode_modes[] = { "Blink 1", "Blink 2", "Blink 3", "Solid", "Zebra 1", "Zebra 2" }; 
    827 static const char* gui_zebra_draw_osd_modes[] = { "Nothing", "Histo", "OSD" }; 
    828 static CMenuItem zebra_submenu_items[] = { 
    829     MENU_ITEM(0x5c,LANG_MENU_ZEBRA_DRAW,              MENUITEM_BOOL,                            &conf.zebra_draw, 0 ), 
    830     MENU_ENUM2(0x5f,LANG_MENU_ZEBRA_MODE,             &conf.zebra_mode, gui_zebra_mode_modes ), 
    831     MENU_ITEM(0x58,LANG_MENU_ZEBRA_UNDER,             MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.zebra_under,   MENU_MINMAX(0, 32) ), 
    832     MENU_ITEM(0x57,LANG_MENU_ZEBRA_OVER,              MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.zebra_over,    MENU_MINMAX(0, 32) ), 
    833     MENU_ITEM(0x28,LANG_MENU_ZEBRA_RESTORE_SCREEN,    MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,      &conf.zebra_restore_screen,     (int)cb_zebra_restore_screen ), 
    834     MENU_ITEM(0x5c,LANG_MENU_ZEBRA_RESTORE_OSD,       MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,      &conf.zebra_restore_osd,        (int)cb_zebra_restore_osd ), 
    835     MENU_ENUM2(0x5f,LANG_MENU_ZEBRA_DRAW_OVER,        &conf.zebra_draw_osd, gui_zebra_draw_osd_modes ), 
    836     MENU_ITEM(0x5c,LANG_MENU_ZEBRA_MULTICHANNEL,      MENUITEM_BOOL,                            &conf.zebra_multichannel, 0 ), 
    837     MENU_ITEM(0x51,LANG_MENU_BACK,                    MENUITEM_UP, 0, 0 ), 
    838     {0} 
    839 }; 
    840 static CMenu zebra_submenu = {0x26,LANG_MENU_ZEBRA_TITLE, NULL, zebra_submenu_items }; 
    841  
    842 #ifdef OPT_CURVES 
    843 static CMenuItem curve_submenu_items[] = { 
    844     MENU_ITEM(0x5f,LANG_MENU_CURVE_ENABLE,        MENUITEM_ENUM,      gui_conf_curve_enum, 0 ), 
    845     MENU_ITEM(0x35,LANG_MENU_CURVE_LOAD,          MENUITEM_PROC,      gui_load_curve, 0 ), 
    846     MENU_ITEM(0x51,LANG_MENU_BACK,                MENUITEM_UP, 0, 0 ), 
    847     {0} 
    848 }; 
    849 static CMenu curve_submenu = {0x85,LANG_MENU_CURVE_PARAM_TITLE, NULL, curve_submenu_items }; 
    850 #endif 
    851  
    852755static CMenuItem root_menu_items[] = { 
    853756    MENU_ITEM(0x21,LANG_MENU_OPERATION_PARAM,         MENUITEM_SUBMENU,   &operation_submenu, 0 ), 
     
    855758    MENU_ITEM(0x24,LANG_MENU_MAIN_RAW_PARAM,          MENUITEM_SUBMENU,   &raw_submenu, 0 ), 
    856759#ifdef OPT_EDGEOVERLAY 
    857     MENU_ITEM(0x7f,LANG_MENU_EDGE_OVERLAY,         MENUITEM_SUBMENU,   &edge_overlay_submenu, 0 ), 
     760    MENU_ITEM(0x7f,LANG_MENU_EDGE_OVERLAY,            MENUITEM_SUBMENU_PROC, gui_menu_run_fltmodule, "edgeovr.flt" ), 
    858761#endif 
    859762#ifdef OPT_CURVES 
    860     MENU_ITEM(0x85,LANG_MENU_CURVE_PARAM,             MENUITEM_SUBMENU,   &curve_submenu, 0 ), 
     763    MENU_ITEM(0x85,LANG_MENU_CURVE_PARAM,             MENUITEM_SUBMENU_PROC, gui_menu_run_fltmodule, "curves.flt" ), 
    861764#endif 
    862765    MENU_ITEM(0x25,LANG_MENU_MAIN_HISTO_PARAM,        MENUITEM_SUBMENU,   &histo_submenu, 0 ), 
    863     MENU_ITEM(0x26,LANG_MENU_MAIN_ZEBRA_PARAM,        MENUITEM_SUBMENU,   &zebra_submenu, 0 ), 
     766    MENU_ITEM(0x26,LANG_MENU_MAIN_ZEBRA_PARAM,        MENUITEM_SUBMENU_PROC, gui_menu_run_fltmodule, "zebra.flt" ), 
    864767    MENU_ITEM(0x22,LANG_MENU_MAIN_OSD_PARAM,          MENUITEM_SUBMENU,   &osd_submenu, 0 ), 
    865768    MENU_ITEM(0x28,LANG_MENU_MAIN_VISUAL_PARAM,       MENUITEM_SUBMENU,   &visual_submenu, 0 ), 
     
    994897} 
    995898 
    996 void cb_zebra_restore_screen() { 
    997     if (!conf.zebra_restore_screen) 
    998         conf.zebra_restore_osd = 0; 
    999 } 
    1000  
    1001 void cb_zebra_restore_osd() { 
    1002     if (conf.zebra_restore_osd) 
    1003         conf.zebra_restore_screen = 1; 
    1004 } 
    1005  
    1006899#if DNG_SUPPORT 
    1007900void cb_change_dng(){ 
     
    1030923save memory by eliminating dupe code 
    1031924*/ 
    1032 static void gui_enum_value_change(int *value, int change, unsigned num_items) { 
     925void gui_enum_value_change(int *value, int change, unsigned num_items) { 
    1033926    *value+=change; 
    1034927    if (*value<0) 
     
    1047940    return items[*menu_item->value]; 
    1048941} 
    1049  
    1050 //------------------------------------------------------------------- 
    1051 #ifdef OPT_CURVES 
    1052 const char* gui_conf_curve_enum(int change, int arg) { 
    1053     static const char* modes[]={ "None", "Custom", "+1EV", "+2EV", "Auto DR" }; 
    1054  
    1055     gui_enum_value_change(&conf.curve_enable,change,sizeof(modes)/sizeof(modes[0])); 
    1056  
    1057         if(change && libcurves && libcurves->curve_init_mode) 
    1058                 libcurves->curve_init_mode(); 
    1059     return modes[conf.curve_enable]; 
    1060 } 
    1061 #endif 
    1062942 
    1063943#ifdef OPT_SCRIPTING 
     
    14961376conf.menu_symbol_rbf_file[0] = 0; 
    14971377conf.menu_rbf_file[0] = 0; 
     1378conf.charmap_file[0] = 0; 
    14981379conf_save(); 
    14991380gui_mbox_init(LANG_INFORMATION, LANG_MENU_RESTART_CAMERA, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 
     
    16211502    } 
    16221503    gui_splash = (conf.splash_show)?SPLASH_TIME:0; 
    1623  
     1504    user_menu_restore(); 
    16241505    gui_lang_init(); 
    16251506    draw_init(); 
     
    16291510    load_from_file( "A/CHDK/badpixel", make_pixel_list ); 
    16301511    load_from_file( "A/CHDK/badpixel.txt", make_pixel_list ); 
    1631 #ifdef OPT_CURVES 
    1632         // initialize curves, loading files if required by current mode 
    1633         //curve_init_mode();    // @tsv it will be initialize on first load 
    1634 #endif 
    16351512#if ZOOM_OVERRIDE 
    16361513// reyalp - need to do this in capt_seq 
     
    16411518 
    16421519//------------------------------------------------------------------- 
    1643 void gui_modules_menu_load(int arg){ 
    1644  
    1645         misc_submenu_items[1].type=MENUITEM_TEXT; 
    1646  
    1647         unsigned int argv[] ={  (unsigned int)MODULES_PATH, 
    1648                                                         (unsigned int)(&misc_submenu_items[1]) 
    1649                                                  }; 
    1650         module_run("modmenu.flt", 0, 2,argv, UNLOAD_IF_ERR ); 
    1651 } 
    1652  
    1653 //------------------------------------------------------------------- 
    1654 #ifdef OPT_CURVES 
    1655 static void gui_load_curve_selected(const char *fn) { 
    1656         if (fn) { 
    1657                 // TODO we could sanity check here, but curve_set_type should fail gracefullish 
    1658                 strcpy(conf.curve_file,fn); 
    1659                 if(conf.curve_enable == 1 && libcurves && libcurves->curve_init_mode) 
    1660                         libcurves->curve_init_mode(); 
    1661         } 
    1662 } 
    1663  
    1664 //------------------------------------------------------------------- 
    1665 void gui_load_curve(int arg) { 
    1666     module_fselect_init(LANG_STR_SELECT_CURVE_FILE, conf.curve_file, CURVE_DIR, gui_load_curve_selected); 
    1667 } 
    1668  
    1669 #endif 
    1670  
     1520//void gui_modules_menu_load(){ 
     1521// 
     1522//      misc_submenu_items[1].type=MENUITEM_TEXT; 
     1523// 
     1524//      unsigned int argv[] ={  (unsigned int)MODULES_PATH, 
     1525//                                                      (unsigned int)(&misc_submenu_items[1]) 
     1526//                                               }; 
     1527//      module_run("modmenu.flt", 0, 2,argv, UNLOAD_IF_ERR ); 
     1528//} 
    16711529 
    16721530//------------------------------------------------------------------- 
     
    17831641        { 
    17841642            --show_md_grid; 
    1785             md_draw_grid(); 
     1643            if (module_mdetect_load()) 
     1644                libmotiondetect->md_draw_grid(); 
    17861645        } 
    17871646    } 
     
    19611820} 
    19621821 
    1963 // Menu button handled for Menu mode 
     1822// Menu button handler for Menu mode 
    19641823void gui_menu_kbd_process_menu_btn() 
    19651824{ 
     1825    gui_menu_unload_module_menus(); 
    19661826#ifdef OPTIONS_AUTOSAVE 
    19671827    conf_save_new_settings_if_changed(); 
     
    20001860        flag_gui_enforce_redraw |= GUI_REDRAWFLAG_ERASEGUARD; 
    20011861        //gui_menu_force_redraw(); 
    2002         //gui_fselect_force_redraw();   //@tsv 
    20031862#ifdef CAM_TOUCHSCREEN_UI 
    20041863        extern int redraw_buttons; 
     
    20991958    gui_set_mode(&defaultGuiHandler); 
    21001959 
    2101         // Unload all modules which are marked as safe to unload 
     1960        // Unload all modules which are marked as safe to unload, or loaded for menus 
     1961    gui_menu_unload_module_menus(); 
    21021962        module_async_unload_allrunned(0); 
    21031963 
     
    24502310                return; 
    24512311 
    2452         if (gui_osd_draw_zebra(conf.zebra_draw && gui_get_mode()==GUI_MODE_NONE && 
     2312    if (conf.zebra_draw) 
     2313        if (module_zebra_load()) 
     2314                if (libzebra->gui_osd_draw_zebra(conf.zebra_draw && gui_get_mode()==GUI_MODE_NONE && 
    24532315                                                        kbd_is_key_pressed(KEY_SHOOT_HALF) && mode_photo && 
    24542316                                                        !state_kbd_script_run)) {// no zebra when script running, to save mem 
    2455                 return; // if zebra drawn, we're done 
     2317                        return; // if zebra drawn, we're done 
    24562318        } 
    24572319#if !CAM_SHOW_OSD_IN_SHOOT_MENU 
     
    24712333 
    24722334    if ((m&MODE_MASK) == MODE_REC && (recreview_hold==0 || conf.show_osd_in_review) ) { 
    2473         if (conf.show_grid_lines) { 
    2474             gui_grid_draw_osd(1); 
    2475         } 
     2335        if (conf.show_grid_lines) 
     2336            if (module_grids_load()) 
     2337                libgrids->gui_grid_draw_osd(1); 
    24762338        if ((gui_get_mode()==GUI_MODE_NONE || gui_get_mode()==GUI_MODE_ALT) && (((kbd_is_key_pressed(KEY_SHOOT_HALF) || (state_kbd_script_run) || (shooting_get_common_focus_mode())) && (mode_photo || (m&MODE_SHOOTING_MASK)==MODE_STITCH )) || ((mode_video || movie_status > 1) && conf.show_values_in_video) )) { 
    24772339 
     
    26522514 
    26532515//------------------------------------------------------------------- 
    2654 static void gui_grid_lines_load_selected(const char *fn) { 
    2655     if (fn) 
    2656         grid_lines_load(fn); 
    2657 } 
    2658 void gui_grid_lines_load(int arg) { 
    2659     module_fselect_init(LANG_STR_SELECT_GRID_FILE, conf.grid_lines_file, "A/CHDK/GRIDS", gui_grid_lines_load_selected); 
    2660 } 
    2661  
    2662 //------------------------------------------------------------------- 
    2663 #ifdef OPT_TEXTREADER 
    2664 static void gui_draw_read_selected(const char *fn) { 
    2665     if (fn) { 
    2666         if (!rbf_load(conf.reader_rbf_file)) 
    2667             rbf_load_from_8x16(current_font); 
    2668         rbf_set_codepage(conf.reader_codepage); 
    2669  
    2670                 unsigned int argv[] ={ (unsigned int)fn }; 
    2671                 module_run("txtread.flt", 0, sizeof(argv)/sizeof(argv[0]), argv, UNLOAD_IF_ERR); 
    2672     } 
    2673 } 
    2674  
    2675 void gui_draw_read(int arg) { 
    2676     module_fselect_init_w_mode(LANG_STR_SELECT_TEXT_FILE, conf.reader_file, "A/CHDK/BOOKS", gui_draw_read_selected, 1); 
    2677     void gui_fselect_set_key_redraw(int n); 
    2678     //gui_fselect_set_key_redraw(1);    @tsv 
    2679 } 
    2680  
    2681 void gui_draw_read_last(int arg) { 
    2682     struct stat st; 
    2683     if (stat(conf.reader_file,&st) == 0) { 
    2684         gui_draw_read_selected(conf.reader_file); 
    2685     } else { 
    2686         gui_draw_read(arg); 
    2687     } 
    2688 } 
    2689 #endif 
    2690  
    2691 //------------------------------------------------------------------- 
    26922516void gui_menuproc_mkbootdisk(int arg) { 
    26932517    mark_filesystem_bootable(); 
     
    26952519} 
    26962520 
    2697 #ifdef OPT_EDGEOVERLAY 
    2698 static void gui_load_edge_selected( const char* fn ) { 
    2699     if( fn && module_edgeovr_load()) 
    2700                 libedgeovr->load_edge_overlay(fn); 
    2701 } 
    2702  
    2703 void gui_menuproc_edge_save(int arg) { 
    2704         if ( module_edgeovr_load() ) 
    2705         libedgeovr->save_edge_overlay(); 
    2706 } 
    2707  
    2708 void gui_menuproc_edge_load(int arg) { 
    2709     module_fselect_init(LANG_MENU_EDGE_LOAD, EDGE_SAVE_DIR, EDGE_SAVE_DIR, gui_load_edge_selected); 
    2710 } 
    2711 #endif 
    2712  
    2713 //------------------------------------------------------------------- 
    2714 #ifdef OPT_TEXTREADER 
    2715 static void gui_draw_rbf_selected(const char *fn) { 
    2716     if (fn) { 
    2717         strcpy(conf.reader_rbf_file, fn); 
    2718     } 
    2719 } 
    2720 void gui_draw_load_rbf(int arg) { 
    2721     module_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.reader_rbf_file, "A/CHDK/FONTS", gui_draw_rbf_selected); 
    2722 } 
    2723 #endif 
    27242521//------------------------------------------------------------------- 
    27252522static void gui_draw_menu_rbf_selected(const char *fn) { 
     
    27582555void gui_draw_load_lang(int arg) { 
    27592556    module_fselect_init(LANG_STR_SELECT_LANG_FILE, conf.lang_file, "A/CHDK/LANG", gui_draw_lang_selected); 
     2557} 
     2558 
     2559static void gui_charmap_selected(const char *fn) { 
     2560    if (fn) 
     2561        strcpy(conf.charmap_file, fn); 
     2562} 
     2563static void gui_load_charmap(int arg) { 
     2564    module_fselect_init(LANG_STR_SELECT_CHARMAP_FILE, conf.charmap_file, "A/CHDK", gui_charmap_selected); 
    27602565} 
    27612566 
  • trunk/core/gui_4wins.c

    r1527 r1569  
    1212#include "gui_batt.h" 
    1313#include "gui_mbox.h" 
    14 #include "gui_4wins.h" 
    1514 
    1615#include "module_load.h" 
     
    3231#define P1_COLOR         MAKE_COLOR(COLOR_HISTO_B_PLAY,COLOR_HISTO_B_PLAY) 
    3332#define P2_COLOR         MAKE_COLOR(COLOR_HISTO_G_PLAY,COLOR_HISTO_G_PLAY) 
    34 #define BG_COLOR         MAKE_COLOR(COLOR_GREY,COLOR_GREY) 
     33#define BK_COLOR         MAKE_COLOR(COLOR_GREY,COLOR_GREY) 
    3534#define FIELD_COLOR      MAKE_COLOR(COLOR_SPLASH_GREY,COLOR_SPLASH_GREY)//(füllfarbe,rand) 
    36 #define TEXT_COLOR   MAKE_COLOR(BG_COLOR, COLOR_WHITE) 
     35#define TEXT_COLOR   MAKE_COLOR(COLOR_GREY, COLOR_WHITE) 
    3736#define INFO_COLOR   MAKE_COLOR(COLOR_SPLASH_GREY, COLOR_SPLASH_GREY) 
    3837#define INFO_TEXT_COLOR   MAKE_COLOR(INFO_COLOR, COLOR_WHITE) 
     
    285284static void move_cursor(int in_x_pos) 
    286285{ 
    287         draw_filled_ellipse((XBORDER+((cursor_position)*RECT_SIZE))+15, BORDER+10, 10,10,BG_COLOR); 
     286        draw_filled_ellipse((XBORDER+((cursor_position)*RECT_SIZE))+15, BORDER+10, 10,10,BK_COLOR); 
    288287        if(in_game) 
    289288        { 
     
    312311        srand(time(NULL)); 
    313312         
    314         draw_filled_rect(0, 0, camera_screen.width, camera_screen.height, BG_COLOR);            // draw backgraund 
     313        draw_filled_rect(0, 0, camera_screen.width, camera_screen.height, BK_COLOR);            // draw backgraund 
    315314        draw_filled_rect(XBORDER, BORDER+BORDER_TOP, XBORDER+(7*RECT_SIZE), BORDER+(6*RECT_SIZE)+BORDER_TOP, FIELD_COLOR); 
    316315        draw_filled_round_rect(camera_screen.ts_button_border+240, 90, camera_screen.ts_button_border+360-BORDER, 240-10, INFO_COLOR); 
     
    323322                { 
    324323                        field[i][j+1]=0; 
    325                         draw_filled_ellipse(XBORDER+(i*RECT_SIZE)+(RECT_SIZE/2), BORDER+(j*RECT_SIZE)+(RECT_SIZE/2)+BORDER_TOP, 10, 10, BG_COLOR); 
     324                        draw_filled_ellipse(XBORDER+(i*RECT_SIZE)+(RECT_SIZE/2), BORDER+(j*RECT_SIZE)+(RECT_SIZE/2)+BORDER_TOP, 10, 10, BK_COLOR); 
    326325                } 
    327326        } 
  • trunk/core/gui_batt.c

    r1355 r1569  
    7070#else 
    7171 
    72     color cl = (perc<=20)?conf.osd_color_warn:(conf.batt_icon_color&0xFF); 
     72    color cl = (perc<=20)?conf.osd_color_warn:FG_COLOR(conf.batt_icon_color); 
    7373 
    7474    // battery icon 
  • trunk/core/gui_calendar.c

    r1527 r1569  
    7777    draw_filled_rect(cal_x-1, cal_y+FONT_HEIGHT+8, cal_x+cal_w, cal_y+cal_h, CALENDAR_COLOR); 
    7878 
    79     draw_filled_rect(cal_x+cal_w-FONT_WIDTH*4*2, cal_y+FONT_HEIGHT+8+1, cal_x+cal_w-1, cal_y+cal_h-1, MAKE_COLOR(((WEEKEND_COLOR)>>8), ((WEEKEND_COLOR)>>8))); 
     79    draw_filled_rect(cal_x+cal_w-FONT_WIDTH*4*2, cal_y+FONT_HEIGHT+8+1, cal_x+cal_w-1, cal_y+cal_h-1, MAKE_COLOR(BG_COLOR(WEEKEND_COLOR), BG_COLOR(WEEKEND_COLOR))); 
    8080    for (x=cal_x+FONT_WIDTH/2, i=0; i<7; x+=FONT_WIDTH*4, ++i) { 
    8181        draw_string(x, cal_y+4+FONT_HEIGHT+4+4, lang_str(days[i]), (i<5)?CALENDAR_COLOR:WEEKEND_COLOR); 
     
    150150        x = cal_x + (cal_w-FONT_WIDTH*2-FONT_WIDTH*4-FONT_WIDTH*2-i*FONT_WIDTH)/2; 
    151151        y = cal_y + 4; 
    152         draw_filled_rect(cal_x+FONT_WIDTH, y, cal_x+cal_w-FONT_WIDTH-FONT_WIDTH*4-FONT_WIDTH, y+FONT_HEIGHT, MAKE_COLOR(((TITLE_COLOR)>>8), ((TITLE_COLOR)>>8))); 
     152        draw_filled_rect(cal_x+FONT_WIDTH, y, cal_x+cal_w-FONT_WIDTH-FONT_WIDTH*4-FONT_WIDTH, y+FONT_HEIGHT, MAKE_COLOR(BG_COLOR(TITLE_COLOR), BG_COLOR(TITLE_COLOR))); 
    153153        draw_string(x+FONT_WIDTH, y, lang_str(months[cal_month]), TITLE_COLOR); 
    154154         
  • trunk/core/gui_debug.c

    r1527 r1569  
    1111 
    1212extern void gui_module_menu_kbd_process(); 
    13 int *conf_mem_view_addr_init; 
    1413 
    1514gui_handler GUI_MODE_DEBUG =  
     
    106105            else 
    107106                gui_debug_draw_values(8, addr); 
    108             *conf_mem_view_addr_init = (long)addr; 
     107            conf.mem_view_addr_init = (long)addr; 
    109108 
    110109            if (debug_cont_update==0) debug_to_draw = 0; 
     
    189188// RETURN VALUE: 1 error, 0 ok 
    190189//--------------------------------------------------------- 
    191 int _module_loader( void** chdk_export_list ) 
     190int _module_loader( unsigned int* chdk_export_list ) 
    192191{ 
    193   if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     192  if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    194193     return 1; 
    195194 
     
    198197  if ( !API_VERSION_MATCH_REQUIREMENT( camera_info.api_version, 1, 0 ) ) 
    199198         return 1; 
    200  
    201   tConfigVal configVal; 
    202   CONF_BIND_INT(195, conf_mem_view_addr_init); 
     199  if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 
     200         return 1; 
    203201 
    204202  return 0; 
     
    228226 
    229227  if ( argn== 0 ) 
    230     adr =(char*)(*conf_mem_view_addr_init); 
     228    adr =(char*)(conf.mem_view_addr_init); 
    231229  else if ( argn ==1) 
    232230    adr = (char*)arguments[0];  
  • trunk/core/gui_draw.c

    r1527 r1569  
    203203    register unsigned int x, y; 
    204204 
    205     cl = cl >> 8; 
     205    cl = BG_COLOR(cl); 
    206206    for (y=yMin+1; y<=yMax-1; ++y) 
    207207    { 
     
    240240            for (ii=0; ii<FONT_WIDTH; ii++) 
    241241        { 
    242             draw_pixel(x+ii ,y+i, (sym[i] & (0x80>>ii))? cl&0xff : cl>>8); 
     242            draw_pixel(x+ii ,y+i, (sym[i] & (0x80>>ii))? FG_COLOR(cl) : BG_COLOR(cl)); 
    243243            } 
    244244    } 
     
    392392    long d2xt = 2*b2, d2yt = 2*a2; 
    393393     
    394     color cl_fill = ((cl >> 8) & 0xff) | (cl & 0xff00); 
     394    color cl_fill = MAKE_COLOR(BG_COLOR(cl), BG_COLOR(cl)); 
    395395 
    396396    if (b == 0) { 
  • trunk/core/gui_fselect.c

    r1527 r1569  
    1717#include "module_load.h" 
    1818 
     19/* 
     20        HISTORY:        1.1 - added tbox usage [CHDK 1.1.1 required] 
     21*/ 
     22 
    1923void gui_fselect_kbd_process(); 
    2024void gui_fselect_draw(int enforce_redraw); 
     
    2428 
    2529extern int module_idx; 
    26  
    27 int *conf_sub_batch_prefix; 
    28 int *conf_sub_batch_ext; 
    2930 
    3031struct librawop_sym* librawop_p; 
     
    104105#define MPOPUP_DELETE           0x0008 
    105106#define MPOPUP_SELINV           0x0010 
    106 #define MPOPUP_RAW_ADD          0x0020 
    107 #define MPOPUP_RAW_AVERAGE      0x0040 
    108107#define MPOPUP_PURGE            0x0080 
    109 #define MPOPUP_SUBTRACT         0x0100 
    110 #define MPOPUP_RAW_DEVELOP      0x0200 
    111 #define MPOPUP_DNG_TO_CRW       0x0400 
    112108#define MPOPUP_EDITOR           0x0800 
    113109#define MPOPUP_CHDK_REPLACE     0x1000 
     110 
     111#define MPOPUP_RAWOPS                   0x0020 
     112#define MPOPUP_MORE                             0x0040 
     113 
    114114 
    115115static struct mpopup_item popup[]= { 
     
    119119        { MPOPUP_DELETE,        LANG_POPUP_DELETE }, 
    120120        { MPOPUP_SELINV,        LANG_POPUP_SELINV }, 
     121        { MPOPUP_PURGE,         LANG_POPUP_PURGE  }, 
     122        { MPOPUP_EDITOR,        (int)"Edit" }, 
     123        { MPOPUP_CHDK_REPLACE,  (int)"Set this CHDK" }, 
     124        { MPOPUP_RAWOPS,                (int)"Raw ops ->" }, 
     125        { MPOPUP_MORE,                  (int)"More -> " }, 
     126        { 0,                                    0 }, 
     127}; 
     128 
     129#define MPOPUP_RAW_ADD                  0x0020 
     130#define MPOPUP_RAW_AVERAGE              0x0040 
     131#define MPOPUP_SUBTRACT         0x0100 
     132#define MPOPUP_RAW_DEVELOP      0x0200 
     133#define MPOPUP_DNG_TO_CRW       0x0400 
     134 
     135static struct mpopup_item popup_rawop[]= { 
    121136        { MPOPUP_RAW_ADD,       LANG_POPUP_RAW_SUM}, 
    122137        { MPOPUP_RAW_AVERAGE,   LANG_POPUP_RAW_AVERAGE }, 
    123138        { MPOPUP_RAW_DEVELOP,   LANG_MENU_RAW_DEVELOP }, 
    124         { MPOPUP_PURGE,         LANG_POPUP_PURGE  }, 
    125139        { MPOPUP_SUBTRACT,      LANG_POPUP_SUB_FROM_MARKED  }, 
    126140        { MPOPUP_DNG_TO_CRW,    (int)"DNG -> CHDK RAW"}, 
    127         { MPOPUP_EDITOR,        (int)"Edit" }, 
    128         { MPOPUP_CHDK_REPLACE,  (int)"Set this CHDK" }, 
     141        { 0,                                    0 }, 
     142}; 
     143 
     144#define MPOPUP_MKDIR  0x0001 
     145#define MPOPUP_RMDIR  0x0002 
     146#define MPOPUP_RENAME 0x0004 
     147 
     148static struct mpopup_item popup_more[]= { 
     149        { MPOPUP_MKDIR,         LANG_POPUP_MKDIR }, 
     150        { MPOPUP_RMDIR,                 (int)"Remove dir" }, 
     151        { MPOPUP_RENAME,                LANG_POPUP_RENAME }, 
    129152        { 0,                                    0 }, 
    130153}; 
     
    396419    gui_fselect_mode_old = gui_set_mode(&GUI_MODE_FSELECT_MODULE); 
    397420    gui_fselect_set_key_redraw(0); 
    398 } 
    399  
    400 //------------------------------------------------------------------- 
    401 char* gui_fselect_result() { 
    402     if (selected_file[0]) 
    403         return selected_file; 
    404     else 
    405         return NULL; 
    406421} 
    407422 
     
    10031018            (strcmp(ptr->name,selected->name)) != 0) { 
    10041019            sprintf(raw_subtract_from,"%s/%s",current_dir,ptr->name); 
    1005             sprintf(raw_subtract_dest,"%s/%s%s",current_dir,img_prefixes[*conf_sub_batch_prefix],ptr->name+4); 
    1006             strcpy(raw_subtract_dest + strlen(raw_subtract_dest) - 4,img_exts[*conf_sub_batch_ext]); 
     1020            sprintf(raw_subtract_dest,"%s/%s%s",current_dir,img_prefixes[conf.sub_batch_prefix],ptr->name+4); 
     1021            strcpy(raw_subtract_dest + strlen(raw_subtract_dest) - 4,img_exts[conf.sub_batch_ext]); 
    10071022            // don't let users attempt to write one of the files being read 
    10081023            if( strcmp(raw_subtract_dest,raw_subtract_from) != 0 && strcmp(raw_subtract_dest,raw_subtract_sub) != 0) { 
     
    10631078  gui_fselect_read_dir(current_dir); 
    10641079} 
     1080 
     1081 
     1082 
     1083static void fselect_mpopup_rawop_cb(unsigned int actn) { 
     1084    switch (actn) { 
     1085            case MPOPUP_RAW_AVERAGE: 
     1086            raw_operation=RAW_OPERATION_AVERAGE; 
     1087            process_raw_files(); 
     1088            break; 
     1089        case MPOPUP_RAW_ADD: 
     1090            raw_operation=RAW_OPERATION_SUM; 
     1091            process_raw_files(); 
     1092            break; 
     1093        case MPOPUP_RAW_DEVELOP: 
     1094            sprintf(buf, "%s/%s", current_dir, selected->name); 
     1095            gui_mbox_init((int)"", LANG_RAW_DEVELOP_MESSAGE, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 
     1096            raw_prepare_develop(buf); 
     1097        break; 
     1098        case MPOPUP_SUBTRACT: 
     1099            setup_batch_subtract(); 
     1100            break; 
     1101            case MPOPUP_DNG_TO_CRW: 
     1102            process_dng_to_raw_files(); 
     1103            break; 
     1104        } 
     1105} 
     1106 
     1107static void mkdir_cb(char* name) 
     1108{ 
     1109        if (name) { 
     1110                sprintf(selected_file,"%s/%s",current_dir,name); 
     1111                mkdir(selected_file);            
     1112                gui_fselect_read_dir(current_dir); 
     1113            gui_fselect_redraw = 2; 
     1114        } 
     1115} 
     1116 
     1117static void rename_cb(char* name) 
     1118{ 
     1119        if (name) { 
     1120                char newname[100]; 
     1121        sprintf(selected_file, "%s/%s", current_dir, selected->name); 
     1122                sprintf(newname,"%s/%s",current_dir,name); 
     1123                rename(selected_file,newname); 
     1124                gui_fselect_read_dir(current_dir); 
     1125            gui_fselect_redraw = 2; 
     1126        } 
     1127} 
     1128 
     1129static void fselect_mpopup_more_cb(unsigned int actn) { 
     1130 
     1131    switch (actn) { 
     1132            case MPOPUP_MKDIR: 
     1133                        module_tbox_run( LANG_POPUP_MKDIR, LANG_PROMPT_MKDIR, "", 15, mkdir_cb); 
     1134            break; 
     1135        case MPOPUP_RMDIR: 
     1136                         gui_mbox_init( LANG_ERROR, (int)"Not implemented yet", MBOX_FUNC_RESTORE|MBOX_TEXT_LEFT, NULL); 
     1137            break; 
     1138        case MPOPUP_RENAME: 
     1139                        module_tbox_run( LANG_POPUP_RENAME, LANG_PROMPT_RENAME, selected->name, 15, rename_cb); 
     1140            break; 
     1141        } 
     1142    gui_fselect_redraw = 2; 
     1143} 
     1144 
     1145static int mpopup_rawop_flag; 
     1146static int mpopup_more_flag; 
    10651147 
    10661148//------------------------------------------------------------------- 
     
    11191201        case MPOPUP_CANCEL: 
    11201202            break; 
    1121     case MPOPUP_RAW_AVERAGE: 
    1122         raw_operation=RAW_OPERATION_AVERAGE; 
    1123             process_raw_files(); 
    1124             break; 
    1125         case MPOPUP_RAW_ADD: 
    1126             raw_operation=RAW_OPERATION_SUM; 
    1127             process_raw_files(); 
    1128             break; 
    1129         case MPOPUP_RAW_DEVELOP: 
    1130             sprintf(buf, "%s/%s", current_dir, selected->name); 
    1131             gui_mbox_init((int)"", LANG_RAW_DEVELOP_MESSAGE, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 
    1132             raw_prepare_develop(buf); 
     1203 
     1204                case MPOPUP_RAWOPS: 
     1205            module_mpopup_init( popup_rawop, mpopup_rawop_flag, fselect_mpopup_rawop_cb, 0); 
     1206            break; 
     1207 
     1208                case MPOPUP_MORE:                        
     1209            module_mpopup_init( popup_more, mpopup_more_flag, fselect_mpopup_more_cb, 0); 
    11331210        break; 
     1211 
    11341212        case MPOPUP_CHDK_REPLACE: 
    11351213            gui_mbox_init((int)"Replacing CHDK", (int)"Do you want to replace current CHDK with this file", 
     
    11381216        case MPOPUP_EDITOR: 
    11391217            gui_mbox_init((int)"Editor", (int)"edit", MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 
    1140             break; 
    1141         case MPOPUP_SUBTRACT: 
    1142         { 
    1143             setup_batch_subtract(); 
    1144             break; 
    1145         } 
    1146     case MPOPUP_DNG_TO_CRW: 
    1147             process_dng_to_raw_files(); 
    11481218            break; 
    11491219    } 
     
    12241294            if (selected && selected->attr != 0xFF) { 
    12251295                i=MPOPUP_CUT|MPOPUP_COPY|MPOPUP_SELINV; 
     1296                                mpopup_rawop_flag=0; 
    12261297                if (fselect_marked_count() > 0) { 
    12271298                    i |= MPOPUP_DELETE; 
    12281299                    if ( fselect_marked_count()>1 ) 
    1229                         i |=MPOPUP_RAW_ADD|MPOPUP_RAW_AVERAGE; 
     1300                        mpopup_rawop_flag |=MPOPUP_RAW_ADD|MPOPUP_RAW_AVERAGE; 
    12301301                    // doesn't make sense to subtract from itself! 
    12311302                    if( selected->marked == 0 && fselect_real_marked_count() > 0) 
    1232                         i |= MPOPUP_SUBTRACT; 
     1303                        mpopup_rawop_flag |= MPOPUP_SUBTRACT; 
    12331304                } 
     1305 
     1306                                if ( API_VERSION_MATCH_REQUIREMENT( module_tbox_get_version(), 1, 0 ) )  
     1307                                                i |= MPOPUP_MORE; 
     1308 
    12341309                if (marked_operation == MARKED_OP_CUT || marked_operation == MARKED_OP_COPY) 
    12351310                    i |= MPOPUP_PASTE; 
     
    12391314                    i |= MPOPUP_PURGE;//Display PURGE RAW function in popup menu 
    12401315                if(selected->size == hook_raw_size()) 
    1241                     i |= MPOPUP_RAW_DEVELOP; 
     1316                    mpopup_rawop_flag |= MPOPUP_RAW_DEVELOP; 
    12421317 
    12431318                                if ( module_convert_dng_to_chdk_raw(0) )        // if dng module exist 
    12441319                if((fselect_marked_count()>1)||(selected->size > hook_raw_size())) 
    1245                     i |= MPOPUP_DNG_TO_CRW; 
     1320                        mpopup_rawop_flag |= MPOPUP_DNG_TO_CRW; 
    12461321 
    12471322                if (selected->name[9] == 'B' && selected->name[10] == 'I' && selected->name[11] == 'N') //If item is DCIM folder 
    12481323                    i |= MPOPUP_CHDK_REPLACE; 
     1324 
     1325                                if ( mpopup_rawop_flag ) 
     1326                                        i |= MPOPUP_RAWOPS; 
     1327 
     1328 
     1329                                mpopup_more_flag = MPOPUP_MKDIR; 
     1330                                if (selected->attr & DOS_ATTR_DIRECTORY) 
     1331                        mpopup_more_flag |=MPOPUP_RMDIR; 
     1332                if ( !(selected->name[0] == '.' && selected->name[1] == '.' && selected->name[2] == 0) ) //If item is not UpDir 
     1333                        mpopup_more_flag |=MPOPUP_RENAME; 
    12491334 
    12501335                module_mpopup_init( popup, i, fselect_mpopup_cb, 0); 
     
    13241409// RETURN VALUE: 1 error, 0 ok 
    13251410//--------------------------------------------------------- 
    1326 int _module_loader( void** chdk_export_list ) 
     1411int _module_loader( unsigned int* chdk_export_list ) 
    13271412{ 
    1328   if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     1413  if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    13291414     return 1; 
    13301415 
    13311416  if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) ) 
    13321417          return 1; 
    1333  
    1334   tConfigVal configVal; 
    1335   CONF_BIND_INT(209, conf_sub_batch_prefix); 
    1336   CONF_BIND_INT(210, conf_sub_batch_ext); 
     1418  if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 
     1419         return 1; 
    13371420 
    13381421  return 0; 
     
    13921475                                                                        0,                                                      // flag 
    13931476                                                                        -LANG_MENU_MISC_FILE_BROWSER,   // Module name 
    1394                                                                         1, 0,                                           // Module version 
     1477                                                                        1, 1,                                           // Module version 
    13951478                                                                        0 
    13961479                                                                 }; 
  • trunk/core/gui_fselect.h

    r1527 r1569  
    33 
    44//------------------------------------------------------------------- 
    5 extern void gui_fselect_init(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn)); 
    6 extern char* gui_fselect_result(); 
    7 extern void gui_fselect_force_redraw(); 
    8 extern void finalize_fselect(); 
     5extern void module_fselect_init(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn)); 
     6extern void module_fselect_init_w_mode(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn), unsigned int key_redraw_mode); 
    97//------------------------------------------------------------------- 
    108#endif 
  • trunk/core/gui_grid.c

    r1365 r1569  
    77#include "gui_draw.h" 
    88#include "gui_grid.h" 
    9  
     9#include "gui_menu.h" 
     10#include "gui_lang.h" 
     11 
     12#include "modules.h" 
     13#include "module_exportlist.h" 
     14 
     15//------------------------------------------------------------------- 
     16 
     17typedef struct 
     18{ 
     19    color grid_color; 
     20    char grid_lines_file[100]; 
     21    int grid_force_color; 
     22} GridConf; 
     23 
     24GridConf gconf; 
     25 
     26static ConfInfo conf_info[] = { 
     27    CONF_INFO( 1, gconf.grid_color,             CONF_DEF_VALUE, cl:0, NULL), 
     28    CONF_INFO( 2, gconf.grid_lines_file,        CONF_CHAR_PTR,   ptr:"", NULL), 
     29    CONF_INFO( 3, gconf.grid_force_color,       CONF_DEF_VALUE, i:0, NULL), 
     30}; 
    1031 
    1132//------------------------------------------------------------------- 
     
    143164 
    144165        grid = grid_default; 
    145         fd = open(fn, O_RDONLY, 0777); 
     166        fd = safe_open(fn, O_RDONLY, 0777); 
    146167        if (fd>=0) { 
    147168            int rcnt = read(fd, buf, GRID_BUF_SIZE); 
     
    154175            } 
    155176            close(fd); 
    156             strcpy(conf.grid_lines_file, fn); 
     177            strcpy(gconf.grid_lines_file, fn); 
    157178        } else { 
    158             conf.grid_lines_file[0] = 0; 
     179            gconf.grid_lines_file[0] = 0; 
    159180        } 
    160181 
     
    174195            switch (ptr->type) { 
    175196                case GRID_ELEM_LINE: 
    176                     draw_line(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (conf.grid_force_color)?conf.grid_color:ptr->clf); 
     197                    draw_line(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (gconf.grid_force_color)?gconf.grid_color:ptr->clf); 
    177198                    break; 
    178199                case GRID_ELEM_RECT: 
    179                     draw_rect(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (conf.grid_force_color)?conf.grid_color:ptr->clf); 
     200                    draw_rect(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (gconf.grid_force_color)?gconf.grid_color:ptr->clf); 
    180201                    break; 
    181202                case GRID_ELEM_FILLED_RECT: 
    182                     draw_filled_rect(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (conf.grid_force_color)?conf.grid_color:MAKE_COLOR(ptr->clb, ptr->clf)); 
     203                    draw_filled_rect(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (gconf.grid_force_color)?gconf.grid_color:MAKE_COLOR(ptr->clb, ptr->clf)); 
    183204                    break; 
    184205                case GRID_ELEM_ELLIPSE: 
    185                     draw_ellipse(ptr->x0, ptr->y0, (unsigned int)(ptr->x1), (unsigned int)(ptr->y1), (conf.grid_force_color)?conf.grid_color:ptr->clf); 
     206                    draw_ellipse(ptr->x0, ptr->y0, (unsigned int)(ptr->x1), (unsigned int)(ptr->y1), (gconf.grid_force_color)?gconf.grid_color:ptr->clf); 
    186207                    break; 
    187208                case GRID_ELEM_FILLED_ELLIPSE: 
    188                     draw_filled_ellipse(ptr->x0, ptr->y0, (unsigned int)(ptr->x1), (unsigned int)(ptr->y1), (conf.grid_force_color)?conf.grid_color:MAKE_COLOR(ptr->clf, 0)); 
     209                    draw_filled_ellipse(ptr->x0, ptr->y0, (unsigned int)(ptr->x1), (unsigned int)(ptr->y1), (gconf.grid_force_color)?gconf.grid_color:MAKE_COLOR(ptr->clf, 0)); 
    189210                    break; 
    190211            } 
     
    195216 
    196217//------------------------------------------------------------------- 
     218 
     219static void gui_grid_lines_load_selected(const char *fn) { 
     220    if (fn) 
     221        grid_lines_load(fn); 
     222} 
     223void gui_grid_lines_load(int arg) { 
     224    module_fselect_init(LANG_STR_SELECT_GRID_FILE, gconf.grid_lines_file, "A/CHDK/GRIDS", gui_grid_lines_load_selected); 
     225} 
     226 
     227static CMenuItem grid_submenu_items[] = { 
     228    MENU_ITEM(0x2f,LANG_MENU_SHOW_GRID,         MENUITEM_BOOL,          &conf.show_grid_lines, 0 ), 
     229    MENU_ITEM(0x35,LANG_MENU_GRID_LOAD,         MENUITEM_PROC,          gui_grid_lines_load, 0 ), 
     230    MENU_ITEM(0x0,LANG_MENU_GRID_CURRENT,       MENUITEM_SEPARATOR, 0, 0 ), 
     231    MENU_ITEM(0x0,(int)grid_title,              MENUITEM_TEXT,      0, 0 ), 
     232    MENU_ITEM(0x0,(int)"",                      MENUITEM_SEPARATOR, 0, 0 ), 
     233    MENU_ITEM(0x5c,LANG_MENU_GRID_FORCE_COLOR,  MENUITEM_BOOL,      &gconf.grid_force_color, 0 ), 
     234    MENU_ITEM(0x65,LANG_MENU_GRID_COLOR_LINE,   MENUITEM_COLOR_FG,  &gconf.grid_color, 0 ), 
     235    MENU_ITEM(0x65,LANG_MENU_GRID_COLOR_FILL,   MENUITEM_COLOR_BG,  &gconf.grid_color, 0 ), 
     236    MENU_ITEM(0x51,LANG_MENU_BACK,              MENUITEM_UP, 0, 0 ), 
     237    {0} 
     238}; 
     239static CMenu grid_submenu = {0x2f,LANG_MENU_GRID_TITLE, NULL, grid_submenu_items }; 
     240 
     241// =========  MODULE INIT ================= 
     242 
     243#include "module_load.h" 
     244 
     245 
     246struct libgrids_sym libgrids = { 
     247                        MAKE_API_VERSION(1,0),          // apiver: increase major if incompatible changes made in module,  
     248                                                                                // increase minor if compatible changes made(including extending this struct) 
     249                        gui_grid_draw_osd 
     250}; 
     251 
     252int module_idx=-1; 
     253 
     254/***************** BEGIN OF AUXILARY PART ********************* 
     255  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     256 **************************************************************/ 
     257 
     258void* MODULE_EXPORT_LIST[] = { 
     259        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     260        /* 1 */ (void*)1, 
     261                        &libgrids 
     262                }; 
     263 
     264 
     265//--------------------------------------------------------- 
     266// PURPOSE:   Bind module symbols with chdk.  
     267//              Required function 
     268// PARAMETERS: pointer to chdk list of export 
     269// RETURN VALUE: 1 error, 0 ok 
     270//--------------------------------------------------------- 
     271int _module_loader( unsigned int* chdk_export_list ) 
     272{ 
     273  if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     274     return 1; 
     275 
     276  if ( !API_VERSION_MATCH_REQUIREMENT( camera_sensor.api_version, 1, 0 ) ) 
     277         return 1; 
     278  if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 
     279         return 1; 
     280 
     281  conf_info[0].cl = MAKE_COLOR(COLOR_BG, COLOR_FG); 
     282  config_restore(&conf_info[0], "A/CHDK/MODULES/CFG/grids.cfg", sizeof(conf_info)/sizeof(conf_info[0]), 0, 0); 
     283 
     284  grid_lines_load(gconf.grid_lines_file); 
     285 
     286  return 0; 
     287} 
     288 
     289 
     290 
     291//--------------------------------------------------------- 
     292// PURPOSE: Finalize module operations (close allocs, etc) 
     293// RETURN VALUE: 0-ok, 1-fail 
     294//--------------------------------------------------------- 
     295int _module_unloader() 
     296{ 
     297    config_save(&conf_info[0], "A/CHDK/MODULES/CFG/grids.cfg", sizeof(conf_info)/sizeof(conf_info[0])); 
     298    grid_lines_free_data(); 
     299    return 0; 
     300} 
     301 
     302 
     303//--------------------------------------------------------- 
     304// PURPOSE: Default action for simple modules (direct run) 
     305// NOTE: Please comment this function if no default action and this library module 
     306//--------------------------------------------------------- 
     307int _module_run(int moduleidx, int argn, int* arguments) 
     308{ 
     309  module_idx=moduleidx; 
     310 
     311  gui_activate_sub_menu(&grid_submenu, module_idx); 
     312 
     313  return 0; 
     314} 
     315 
     316 
     317/******************** Module Information structure ******************/ 
     318 
     319struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     320                                                                        sizeof(struct ModuleInfo), 
     321 
     322                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     323                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     324                                                                        MODULEINFO_FLAG_SYSTEM,         // flag 
     325                                                                        (int32_t)"Grids (dll)",     // Module name 
     326                                                                        1, 0,                                           // Module version 
     327                                                                        (int32_t)"Grid Display" 
     328                                                                 }; 
     329 
     330 
     331/*************** END OF AUXILARY PART *******************/ 
  • trunk/core/gui_grid.h

    r515 r1569  
    22#define GUI_GRID_H 
    33 
    4 //------------------------------------------------------------------- 
    5 extern char grid_title[36]; 
     4struct libgrids_sym { 
     5        int version; 
     6 
     7    void (*gui_grid_draw_osd)(int force); 
     8}; 
    69 
    710//------------------------------------------------------------------- 
    8 extern void gui_grid_draw_osd(int force); 
    9 extern void grid_lines_load(const char *fn); 
     11// Defines of exported to chdk symbols 
     12#ifdef THIS_IS_CHDK_CORE 
     13        // This section is for CHDK core 
     14        extern struct libgrids_sym* libgrids; 
     15    extern struct libgrids_sym* module_grids_load();            // 0fail, addr-ok 
     16#else 
     17        // This section is for module 
     18    extern void gui_grid_draw_osd(int force); 
     19    extern void grid_lines_load(const char *fn); 
     20#endif 
     21 
     22extern struct libgrids_sym* module_grids_load();                // 0fail, addr-ok 
     23extern void module_grids_unload(); 
    1024 
    1125//------------------------------------------------------------------- 
  • trunk/core/gui_lang.h

    r1568 r1569  
    594594#define LANG_MENU_REMOTE_OPTIONS 473 
    595595 
     596#define LANG_STR_SELECT_CHARMAP_FILE  474 
     597#define LANG_MENU_VIS_CHARMAP           475 
     598#define LANG_POPUP_MORE                         476 
     599#define LANG_POPUP_MKDIR                        477 
     600#define LANG_POPUP_RENAME                       478 
     601#define LANG_PROMPT_MKDIR                       479 
     602#define LANG_PROMPT_RENAME                      480 
     603 
    596604//------------------------------------------------------------------- 
    597605 
    598 #define GUI_LANG_ITEMS                  473 
     606#define GUI_LANG_ITEMS                  480 
    599607 
    600608//------------------------------------------------------------------- 
  • trunk/core/gui_mastermind.c

    r1527 r1569  
    1010#include "gui_batt.h" 
    1111#include "gui_mbox.h" 
    12 #include "gui_mastermind.h" 
    1312 
    1413#include "module_load.h" 
     
    2524#define RECT_SIZE                       10 
    2625#define COLOR_LIGHT_GRAY        MAKE_COLOR(COLOR_SPLASH_GREY,COLOR_SPLASH_GREY) 
    27 #define BG_COLOR                        MAKE_COLOR(COLOR_GREY,COLOR_GREY) 
    28 #define TEXT_COLOR          MAKE_COLOR(BG_COLOR,COLOR_BLACK) 
     26#define BK_COLOR                        MAKE_COLOR(COLOR_GREY,COLOR_GREY) 
     27#define TEXT_COLOR          MAKE_COLOR(COLOR_GREY,COLOR_BLACK) 
    2928 
    3029int curr_x; 
     
    116115        curr_y=7; 
    117116         
    118         draw_filled_rect( 0, 0, camera_screen.width-1, camera_screen.height-1, BG_COLOR); 
     117        draw_filled_rect( 0, 0, camera_screen.width-1, camera_screen.height-1, BK_COLOR); 
    119118 
    120119        for (i=0;i<4;i++) 
     
    122121                        draw_filled_rect(camera_screen.ts_button_border+BORDER+(2*i*10), BORDER+(2*j*10)+2*j, camera_screen.ts_button_border+BORDER+(2*i*10)+10, BORDER+(2*j*10)+2*j+10 , COLOR_LIGHT_GRAY); 
    123122 
    124         draw_filled_rect(camera_screen.ts_button_border+10, BORDER+(2*j*10)+2*j, camera_screen.ts_button_border+150,BORDER+(2*j*10)+2*j+1, MAKE_COLOR(BG_COLOR,COLOR_WHITE)); 
    125         draw_filled_rect(camera_screen.ts_button_border+148, 10, camera_screen.ts_button_border+149,230, MAKE_COLOR(BG_COLOR,COLOR_WHITE)); 
    126         draw_filled_rect(camera_screen.ts_button_border+151, 10, camera_screen.ts_button_border+152,230, MAKE_COLOR(BG_COLOR,COLOR_WHITE)); 
     123        draw_filled_rect(camera_screen.ts_button_border+10, BORDER+(2*j*10)+2*j, camera_screen.ts_button_border+150,BORDER+(2*j*10)+2*j+1, MAKE_COLOR(COLOR_GREY,COLOR_WHITE)); 
     124        draw_filled_rect(camera_screen.ts_button_border+148, 10, camera_screen.ts_button_border+149,230, MAKE_COLOR(COLOR_GREY,COLOR_WHITE)); 
     125        draw_filled_rect(camera_screen.ts_button_border+151, 10, camera_screen.ts_button_border+152,230, MAKE_COLOR(COLOR_GREY,COLOR_WHITE)); 
    127126         
    128127        for (i=0; i<6;i++) 
     
    233232    static struct tm *ttm; 
    234233 
    235     draw_txt_string(camera_screen.ts_button_border/FONT_WIDTH+15, 0, lang_str(LANG_MENU_GAMES_MASTERMIND), MAKE_COLOR(BG_COLOR, COLOR_WHITE)); 
     234    draw_txt_string(camera_screen.ts_button_border/FONT_WIDTH+15, 0, lang_str(LANG_MENU_GAMES_MASTERMIND), MAKE_COLOR(COLOR_GREY, COLOR_WHITE)); 
    236235 
    237236    t = time(NULL); 
  • trunk/core/gui_menu.c

    r1527 r1569  
    99#include "gui_draw.h" 
    1010#include "modules.h" 
     11#include "module_load.h" 
    1112#include "gui_menu.h" 
    1213#include "gui_lang.h" 
     
    2021    int         curpos; 
    2122    int         toppos; 
     23    int         module_idx; 
    2224} CMenuStacked; 
    2325 
     
    4648 
    4749//------------------------------------------------------------------- 
     50// Unload any module based sub-menus 
     51void gui_menu_unload_module_menus() 
     52{ 
     53    // Unload any module menus 
     54    while (gui_menu_stack_ptr > 0) 
     55    { 
     56        gui_menu_stack_ptr--; 
     57        if (gui_menu_stack[gui_menu_stack_ptr].module_idx >= 0) 
     58            module_unload_idx(gui_menu_stack[gui_menu_stack_ptr].module_idx); 
     59    } 
     60} 
     61 
     62//------------------------------------------------------------------- 
    4863void gui_menu_init(CMenu *menu_ptr) { 
    4964 
    50     static char first_call=1; 
    51  
    5265    if (menu_ptr) { 
    53                 if ( first_call ) { 
    54                         extern void gui_modules_menu_load(); 
    55                         extern void user_menu_restore(); 
    56  
    57                         gui_modules_menu_load(); 
    58                 user_menu_restore(); 
    59                         first_call=0; 
    60                 } 
    61  
    6266        if (conf.menu_select_first_entry) 
    6367            gui_menu_set_curr_menu(menu_ptr, 0, 0); 
     
    105109static void gui_menu_color_selected(color clr) 
    106110{ 
    107     *item_color = (unsigned char)(clr&0xFF); 
     111    *item_color = FG_COLOR(clr); 
    108112    gui_menu_erase_and_redraw(); 
    109113} 
     
    115119    { 
    116120        gui_menu_stack_ptr--; 
     121        if (gui_menu_stack[gui_menu_stack_ptr].module_idx >= 0) 
     122            module_unload_idx(gui_menu_stack[gui_menu_stack_ptr].module_idx); 
    117123        gui_menu_set_curr_menu(gui_menu_stack[gui_menu_stack_ptr].menu, gui_menu_stack[gui_menu_stack_ptr].toppos, gui_menu_stack[gui_menu_stack_ptr].curpos); 
    118124        gui_menu_erase_and_redraw(); 
     
    306312 
    307313// Open a sub-menu 
    308 static void select_sub_menu() 
     314void gui_activate_sub_menu(CMenu *sub_menu, int module_idx) 
    309315{ 
    310316    // push current menu on stack 
     
    312318    gui_menu_stack[gui_menu_stack_ptr].curpos = gui_menu_curr_item; 
    313319    gui_menu_stack[gui_menu_stack_ptr].toppos = gui_menu_top_item; 
     320    gui_menu_stack[gui_menu_stack_ptr].module_idx = module_idx; 
    314321 
    315322    // Select first item in menu, (or none) 
    316323    if (conf.menu_select_first_entry) 
    317324    { 
    318         gui_menu_set_curr_menu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), 0, 0); 
     325        gui_menu_set_curr_menu(sub_menu, 0, 0); 
    319326        if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_TEXT || (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_SEPARATOR) 
    320327        { 
     
    324331    } 
    325332    else  
    326         gui_menu_set_curr_menu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), 0, -1); 
     333        gui_menu_set_curr_menu(sub_menu, 0, -1); 
    327334 
    328335    gui_menu_stack_ptr++; 
     
    337344    // Force full redraw 
    338345    gui_menu_erase_and_redraw(); 
     346} 
     347 
     348// Open a sub-menu 
     349static void select_sub_menu() 
     350{ 
     351    gui_activate_sub_menu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), -1); 
    339352} 
    340353 
     
    505518                        update_bool_value(); 
    506519                        break; 
     520                    case MENUITEM_SUBMENU_PROC: 
    507521                    case MENUITEM_PROC: 
    508522                        if (curr_menu->menu[gui_menu_curr_item].value) 
     
    526540                    case MENUITEM_COLOR_BG: 
    527541                        item_color=((unsigned char*)(curr_menu->menu[gui_menu_curr_item].value)) + (((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)?1:0); 
    528                         module_palette_run(PALETTE_MODE_SELECT, (*item_color)&0xFF, gui_menu_color_selected); 
     542                        module_palette_run(PALETTE_MODE_SELECT, FG_COLOR(*item_color), gui_menu_color_selected); 
    529543                        gui_menu_redraw=2; 
    530544                        break; 
     
    608622// Draw menu scroll bar if needed, and title bar 
    609623void gui_menu_draw_initial() {  
    610     color cl=conf.menu_title_color>>8;  
     624    color cl = BG_COLOR(conf.menu_title_color); 
    611625 
    612626    count = gui_menu_rows(); 
     
    617631        wplus = 8;  
    618632        // scrollbar background  
    619         draw_filled_rect((x+w), y, (x+w)+wplus, y+num_lines*rbf_font_height()-1, MAKE_COLOR((conf.menu_color>>8)&0xFF, (conf.menu_color>>8)&0xFF));  
     633        draw_filled_rect((x+w), y, (x+w)+wplus, y+num_lines*rbf_font_height()-1, MAKE_COLOR(BG_COLOR(conf.menu_color), BG_COLOR(conf.menu_color)));  
    620634    } 
    621635    else 
     
    708722            * when the cursor highlights a line. 
    709723            */ 
    710             cl_symbol = (gui_menu_curr_item==imenu)?MAKE_COLOR((cl>>8)&0xFF,(conf.menu_symbol_color)&0xFF):conf.menu_symbol_color; //color 8Bit=Hintergrund 8Bit=Vordergrund 
     724            cl_symbol = (gui_menu_curr_item==imenu)?MAKE_COLOR(BG_COLOR(cl),FG_COLOR(conf.menu_symbol_color)):conf.menu_symbol_color; //color 8Bit=Hintergrund 8Bit=Vordergrund 
    711725 
    712726            xx = x; 
     
    721735                gui_menu_draw_value(tbuf, len_int); 
    722736                break; 
     737            case MENUITEM_SUBMENU_PROC: 
    723738            case MENUITEM_SUBMENU: 
    724739                sprintf(tbuf, "%s%s", lang_str(curr_menu->menu[imenu].text),(conf.menu_symbol_enable)?"":" ->"); 
     
    746761                if (xx > (x + len_space)) 
    747762                { 
    748                     draw_filled_rect(x+len_space, yy, xx-1, yy+rbf_font_height()/2-1, MAKE_COLOR(cl>>8, cl>>8)); 
     763                    draw_filled_rect(x+len_space, yy, xx-1, yy+rbf_font_height()/2-1, MAKE_COLOR(BG_COLOR(cl), BG_COLOR(cl))); 
    749764                    draw_line(x+len_space, yy+rbf_font_height()/2, xx-1, yy+rbf_font_height()/2, cl); 
    750                     draw_filled_rect(x+len_space, yy+rbf_font_height()/2+1, xx-1, yy+rbf_font_height()-1, MAKE_COLOR(cl>>8, cl>>8)); 
     765                    draw_filled_rect(x+len_space, yy+rbf_font_height()/2+1, xx-1, yy+rbf_font_height()-1, MAKE_COLOR(BG_COLOR(cl), BG_COLOR(cl))); 
    751766                } 
    752767                else 
     
    759774                if (xx < (x+w-len_space)) 
    760775                { 
    761                     draw_filled_rect(xx, yy, x+w-len_space-1, yy+rbf_font_height()/2-1, MAKE_COLOR(cl>>8, cl>>8)); 
     776                    draw_filled_rect(xx, yy, x+w-len_space-1, yy+rbf_font_height()/2-1, MAKE_COLOR(BG_COLOR(cl), BG_COLOR(cl))); 
    762777                    draw_line(xx, yy+rbf_font_height()/2, x+w-1-len_space, yy+rbf_font_height()/2, cl); 
    763                     draw_filled_rect(xx, yy+rbf_font_height()/2+1, x+w-len_space-1, yy+rbf_font_height()-1, MAKE_COLOR(cl>>8, cl>>8)); 
     778                    draw_filled_rect(xx, yy+rbf_font_height()/2+1, x+w-len_space-1, yy+rbf_font_height()-1, MAKE_COLOR(BG_COLOR(cl), BG_COLOR(cl))); 
    764779                } 
    765780 
     
    771786                xx+=rbf_draw_string_len(xx, yy, w-len_space-symbol_width, lang_str(curr_menu->menu[imenu].text), cl); 
    772787                draw_filled_round_rect(x+w-1-cl_rect-2-len_space, yy+2, x+w-1-2-len_space, yy+rbf_font_height()-1-2,  
    773                     MAKE_COLOR(((*(curr_menu->menu[imenu].value))>>(((curr_menu->menu[imenu].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)?8:0))&0xFF,  
    774                                ((*(curr_menu->menu[imenu].value))>>(((curr_menu->menu[imenu].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)?8:0))&0xFF)); 
     788                    MAKE_COLOR(((*(curr_menu->menu[imenu].value))>>(((curr_menu->menu[imenu].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)?16:0))&0xFFFF,  
     789                               ((*(curr_menu->menu[imenu].value))>>(((curr_menu->menu[imenu].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)?16:0))&0xFFFF)); 
    775790                break; 
    776791            case MENUITEM_ENUM: 
  • trunk/core/gui_menu.h

    r1505 r1569  
    1515#define MENUITEM_COLOR_FG       10 
    1616#define MENUITEM_ENUM2          11 
     17#define MENUITEM_SUBMENU_PROC   12 
    1718 
    1819// Flags, which describe limits of F_INT value 
     
    6364extern void gui_menu_init(CMenu *menu_ptr); 
    6465extern void gui_menu_kbd_process(); 
     66extern void gui_menu_kbd_process_menu_btn(); 
    6567extern void gui_menu_draw(int enforce_redraw); 
    6668extern void mod_user_menu(CMenuItem curr_menu_item, int* gui_menu_add_item, int mod); 
    6769extern void gui_menu_force_redraw(); 
     70extern void gui_activate_sub_menu(CMenu *sub_menu, int module_idx); 
     71extern void gui_menu_unload_module_menus(); 
    6872//------------------------------------------------------------------- 
    6973 
  • trunk/core/gui_mpopup.c

    r1527 r1569  
    1313extern int module_idx; 
    1414 
     15/* 
     16        History:        1.1 - make possible call next mpopup in callback [multilevel mpopups] 
     17*/ 
     18 
    1519void gui_mpopup_kbd_process(); 
    1620void gui_mpopup_draw(int enforce_redraw); 
     
    3438static coord                    mpopup_actions_x, mpopup_actions_y;    // top-left coord of window 
    3539static unsigned int             mpopup_actions_w;               // width of window 
    36 static void (*mpopup_on_select)(unsigned int btn); 
     40 
     41typedef void (*mpopup_on_select_t)(unsigned int btn); 
     42static mpopup_on_select_t mpopup_on_select; 
    3743 
    3844//------------------------------------------------------------------- 
     
    112118{ 
    113119    gui_set_mode(gui_mpopup_mode_old); 
    114     if (mpopup_on_select)  
    115         mpopup_on_select(action); 
     120 
     121        mpopup_on_select_t on_select = mpopup_on_select;        // this could be reinited in callback 
     122 
    116123        mpopup_on_select=0; 
     124    if (on_select)  
     125        on_select(action); 
    117126} 
    118127 
     
    136145        kbd_reset_autoclicked_key(); 
    137146                exit_mpopup(MPOPUP_CANCEL);              
     147                if ( mpopup_on_select==0 )              // exit if not re-inited 
    138148                module_async_unload(module_idx); 
    139149        break; 
     
    141151        kbd_reset_autoclicked_key(); 
    142152                exit_mpopup(actions[mpopup_actions[mpopup_actions_active]].flag);                
     153                if ( mpopup_on_select==0 )              // exit if not re-inited 
    143154                module_async_unload(module_idx); 
    144155        break; 
     
    168179// RETURN VALUE: 1 error, 0 ok 
    169180//--------------------------------------------------------- 
    170 int _module_loader( void** chdk_export_list ) 
    171 { 
    172   if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     181int _module_loader( unsigned int* chdk_export_list ) 
     182{ 
     183  if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    173184     return 1; 
    174185 
     
    231242                                                                        MODULEINFO_FLAG_SYSTEM,         // flag 
    232243                                                                        (int32_t)"Popup menu module",           // Module name 
    233                                                                         1, 0,                                           // Module version 
     244                                                                        1, 1,                                           // Module version 
    234245                                                                        0 
    235246                                                                 }; 
  • trunk/core/gui_mpopup.h

    r1527 r1569  
    1212 
    1313//------------------------------------------------------------------- 
    14 extern void gui_mpopup_init(struct mpopup_item* popup_actions, const unsigned int flags, void (*on_select)(unsigned int actn), int mode); 
     14extern void module_mpopup_init(struct mpopup_item* popup_actions, const unsigned int flags, void (*on_select)(unsigned int actn), int mode); 
    1515 
    1616//------------------------------------------------------------------- 
  • trunk/core/gui_osd.c

    r1527 r1569  
    1515#include "gui_grid.h" 
    1616#include "gui_osd.h" 
     17#include "modules.h" 
    1718 
    1819//------------------------------------------------------------------- 
     
    6061static int step; 
    6162 
    62  
    63 #if defined (CAM_ZEBRA_NOBUF) && !defined(CAM_ZEBRA_ASPECT_ADJUST) 
    64 // old sx20 #ifdefs were roughly equivalent of both 
    65         #error "defined (CAM_ZEBRA_NOBUF) && !defined(CAM_ZEBRA_ASPECT_ADJUST). Remove this if you've verified it will work!" 
    66 #endif 
    67  
    68 #ifdef CAM_ZEBRA_ASPECT_ADJUST 
    69 // TODO should just not save anything at all instead of 1 px. Also, this shouldn't be tied to aspect correct 
    70   #define ZEBRA_CANONOSD_BORDER_RESTORE   1 
    71   #define ZFIX_TOP    1 
    72   #define ZFIX_BOTTOM 1 
    73 #else 
    74 // Width (in pixels) of half-shoot Canon OSD area of the screen buffer, for restore during  
    75 // Zebra draw, to limit RAM usage of zebra. Only these border areas are stored in RAM. 
    76 // Only top and bottom are restored, not left&right. 
    77   #define ZEBRA_CANONOSD_BORDER_RESTORE   1 
    78   #define ZFIX_TOP    29 
    79   #define ZFIX_BOTTOM 30 
    80 #endif 
    81  
    82 static unsigned char *img_buf, *scr_buf; 
    83 #if ZEBRA_CANONOSD_BORDER_RESTORE 
    84 static unsigned char *cur_buf_top, *cur_buf_bot; 
    85 #else 
    86 static unsigned char *cur_buf; 
    87 #endif 
    88 static int cur_buf_size; 
    89 static int timer = 0; 
    90 static unsigned char *buf = NULL; 
    91  
    92 #ifdef CAM_ZEBRA_ASPECT_ADJUST 
    93 static int buffer_size; 
    94 #endif 
    95  
    9663static DOF_TYPE dof; 
    9764static EXPO_TYPE expo; 
     
    191158static void gui_osd_draw_single_histo(int hist, coord x, coord y, int small) { 
    192159    register unsigned int i, v, threshold; 
    193     register color cl, cl_over, cl_bg=conf.histo_color>>8; 
     160    register color cl, cl_over, cl_bg = BG_COLOR(conf.histo_color); 
    194161    coord w=HISTO_WIDTH, h=HISTO_HEIGHT; 
    195162 
     
    218185            for (v=1; v<h-1; ++v) 
    219186                draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl:cl_bg); 
    220             cl_over = (threshold==h && conf.show_overexp)?conf.histo_color2>>8:cl; 
     187            cl_over = (threshold==h && conf.show_overexp)?BG_COLOR(conf.histo_color2):cl; 
    221188            for (; v<h; ++v) 
    222189                draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl_over:cl_bg); 
     
    228195            for (v=1; v<h-3; ++v) 
    229196                draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl:cl_bg); 
    230             cl_over = (threshold==h && conf.show_overexp)?conf.histo_color2>>8:cl; 
     197            cl_over = (threshold==h && conf.show_overexp)?BG_COLOR(conf.histo_color2):cl; 
    231198            for (; v<h; ++v) 
    232199                draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl_over:cl_bg); 
     
    234201    } 
    235202       
    236     draw_rect(x, y, x+1+w, y+h, conf.histo_color2&0xFF); 
     203    draw_rect(x, y, x+1+w, y+h, FG_COLOR(conf.histo_color2)); 
    237204    //Vertical Lines 
    238     if (conf.histo_show_ev_grid) for (i=1;i<=4;i++) draw_line(x+(1+w)*i/5, y, x+(1+w)*i/5, y+h, conf.histo_color2&0xFF); 
    239 } 
    240  
    241 //------------------------------------------------------------------- 
    242 // free and NULL zebra buffers. free(NULL) is always OK. 
    243 static void gui_osd_zebra_free() { 
    244 #if !defined (CAM_ZEBRA_NOBUF) 
    245         free(buf); 
    246 #endif 
    247         buf=NULL; 
    248 #if ZEBRA_CANONOSD_BORDER_RESTORE 
    249         free(cur_buf_top); 
    250         cur_buf_top=NULL; 
    251         free(cur_buf_bot); 
    252         cur_buf_bot=NULL; 
    253 #else 
    254         free(cur_buf); 
    255         cur_buf=NULL; 
    256 #endif       
    257 } 
    258 // prepare zebra resources, or free them 
    259 // returns 1 if zebra should be drawn 
    260 static int gui_osd_zebra_init(int show) { 
    261         unsigned i; 
    262  
    263   if(show) 
    264   { 
    265     if (!buf) 
    266     { 
    267       timer = 0; 
    268           #if defined (CAM_ZEBRA_NOBUF) 
    269         buffer_size=camera_screen.buffer_size-ZEBRA_HMARGIN0*camera_screen.buffer_width; 
    270         buf=vid_get_bitmap_fb(); 
    271           #elif defined (CAM_ZEBRA_ASPECT_ADJUST) 
    272         buffer_size=camera_screen.buffer_size-ZEBRA_HMARGIN0*camera_screen.buffer_width; 
    273         buf = malloc(buffer_size); 
    274         //~ if (!buf) draw_txt_string(0, 14, "Warn: No space to allocate zebra buffer: restart camera", MAKE_COLOR(COLOR_ALT_BG, COLOR_FG)); 
    275         if (!buf) 
    276           buf=vid_get_bitmap_fb(); //without new buffer: directly into screen buffer: we got some flickering in OSD and histogram but it's usable 
    277         //~ msleep(50); 
    278       #else 
    279         buf = malloc(camera_screen.buffer_size); 
    280       #endif 
    281             scr_buf = vid_get_bitmap_fb(); 
    282 #if ZEBRA_CANONOSD_BORDER_RESTORE 
    283             cur_buf_top = malloc(camera_screen.buffer_width * ZFIX_TOP);  
    284             cur_buf_bot = malloc(camera_screen.buffer_width * ZFIX_BOTTOM);  
    285 #if defined (CAM_ZEBRA_ASPECT_ADJUST) 
    286             if (cur_buf_top) memset(cur_buf_top,0,camera_screen.buffer_width * ZFIX_TOP); 
    287             if (cur_buf_bot) memset(cur_buf_bot,0,camera_screen.buffer_width * ZFIX_BOTTOM); 
    288 #endif 
    289 #else 
    290             cur_buf = malloc(camera_screen.buffer_size); 
    291 #endif       
    292                         // cleanup and disable zebra if any mallocs failed 
    293                         if(!buf ||  
    294 #if ZEBRA_CANONOSD_BORDER_RESTORE 
    295                                 !cur_buf_top || 
    296                                 !cur_buf_bot  
    297 #else 
    298                                 !cur_buf 
    299 #endif 
    300                                 ) { 
    301                                 gui_osd_zebra_free(); 
    302                         } 
    303 #if CAM_HAS_VARIABLE_ASPECT 
    304                         else // in variable aspect, the borders would never be cleared 
    305                                 memset(buf,0,camera_screen.buffer_size); 
    306 #endif 
    307         } 
    308     } 
    309     else { 
    310                 if(buf) // if zebra was previously on, restore 
    311                         draw_restore(); 
    312  
    313                 gui_osd_zebra_free(); 
    314     } 
    315         return (buf != NULL); 
    316 } 
    317  
    318 //------------------------------------------------------------------- 
    319 static void draw_pixel_buffered(unsigned int offset, color cl) { 
    320 // shouldn't this be checked on all cams ? 
    321    #if defined CAM_ZEBRA_ASPECT_ADJUST 
    322       if (offset < buffer_size) 
    323          buf[offset] = cl; 
    324    #else 
    325       buf[offset] = cl; 
    326    #endif 
    327 } 
    328  
    329 //------------------------------------------------------------------- 
    330 int draw_guard_pixel() { 
    331     unsigned char* buffer1 = vid_get_bitmap_fb()+camera_screen.buffer_size/2; 
    332     unsigned char* buffer2 = buffer1+camera_screen.buffer_size; 
    333     int has_disappeared=0; 
    334  
    335     if(*buffer1!=COLOR_GREEN) has_disappeared=1; 
    336     if(*buffer2!=COLOR_GREEN) has_disappeared=2; 
    337     *buffer1 = *buffer2 = COLOR_GREEN; 
    338     return has_disappeared; 
    339 } 
    340  
    341 //------------------------------------------------------------------- 
    342 #if ZEBRA_CANONOSD_BORDER_RESTORE 
    343 unsigned char get_cur_buf(unsigned int idx) { 
    344     unsigned int a; 
    345      
    346     a=camera_screen.buffer_size - camera_screen.buffer_width * ZFIX_BOTTOM; 
    347      
    348     if (idx < camera_screen.buffer_width * ZFIX_TOP) return(cur_buf_top[idx]); 
    349     if (idx >= a && idx < camera_screen.buffer_size) return(cur_buf_bot[idx - a]); 
    350     return (COLOR_TRANSPARENT); 
    351 } 
    352 #endif 
    353 //------------------------------------------------------------------- 
    354 static void gui_osd_draw_zebra_osd() { 
    355     switch (conf.zebra_draw_osd) { 
    356         case ZEBRA_DRAW_NONE: 
    357             break; 
    358         case ZEBRA_DRAW_OSD: 
    359             if (conf.show_osd) { 
    360                 draw_set_draw_proc(draw_pixel_buffered); 
    361                 if ((mode_get()&MODE_MASK) == MODE_REC) { 
    362                     if (conf.show_dof != DOF_DONT_SHOW) gui_osd_calc_dof(); 
    363                     if (conf.show_grid_lines) { 
    364                         gui_grid_draw_osd(1); 
    365                     } 
    366                     if (conf.show_dof == DOF_SHOW_IN_DOF) { 
    367                         gui_osd_draw_dof(); 
    368                     } 
    369                     if (conf.show_state) { 
    370                         gui_osd_draw_state(); 
    371                     } 
    372                     if (conf.show_remaining_raw) { 
    373                         gui_osd_draw_raw_info(); 
    374                     } 
    375                     if (conf.show_values) { 
    376                         gui_osd_draw_values(); 
    377                     } 
    378                 } 
    379                 gui_batt_draw_osd(); 
    380                 gui_space_draw_osd(); 
    381                 if (conf.show_clock) { 
    382                     gui_osd_draw_clock(0,0,0); 
    383                 } 
    384                 if (conf.show_temp>0) { 
    385                     gui_osd_draw_temp(); 
    386                 } 
    387                 draw_set_draw_proc(NULL); 
    388             } 
    389             /* no break here */ 
    390         case ZEBRA_DRAW_HISTO: 
    391         default: 
    392             if (conf.show_histo) { 
    393                 draw_set_draw_proc(draw_pixel_buffered); 
    394                 gui_osd_draw_histo(); 
    395                 draw_set_draw_proc(NULL); 
    396             } 
    397             break; 
    398     } 
    399 } 
    400  
    401 // reyalp - TODO this should be rewritten so there is one generic zebra func for all cameras 
    402 #if defined(CAM_ZEBRA_ASPECT_ADJUST) 
    403 //nandoide sept-2009  
    404 // viewport is 360x240 and screen buffer 960x270, we need to expand the x coordinate 
    405 //reyalp - applies to other cameras where the real bitmap width is is different from what lib.c reports. Also used on some other cameras ... 
    406 int gui_osd_draw_zebra(int show) { 
    407     unsigned int v, s, x, y, f, over; 
    408     color cl_under=conf.zebra_color>>8, cl_over=conf.zebra_color&0xFF; 
    409     static int need_restore=0; 
    410     int viewport_height; 
    411     int viewport_width;  
    412     int viewport_image_offset;  // for when viewport memory buffer is wider than viewport 
    413     int viewport_row_offset;    // for when viewport memory buffer is wider than viewport 
    414     int viewport_xoffset;       // used when image size != viewport size 
    415     int viewport_yoffset;       // used when image size != viewport size 
    416     int mrec = ((mode_get()&MODE_MASK) == MODE_REC); 
    417     int zebra_drawn=0; 
    418     color cls[] = { 
    419         COLOR_TRANSPARENT, 
    420         (mrec)?COLOR_HISTO_B:COLOR_HISTO_B_PLAY, 
    421         (mrec)?COLOR_HISTO_G:COLOR_HISTO_G_PLAY, 
    422         (mrec)?COLOR_HISTO_BG:COLOR_HISTO_BG_PLAY, 
    423         (mrec)?COLOR_HISTO_R:COLOR_HISTO_R_PLAY, 
    424         (mrec)?COLOR_HISTO_RB:COLOR_HISTO_RB_PLAY, 
    425         (mrec)?COLOR_HISTO_RG:COLOR_HISTO_RG_PLAY, 
    426         COLOR_BLACK 
    427     }; 
    428          
    429     if (!gui_osd_zebra_init(show)) 
    430         return 0; 
    431  
    432     if(timer==0) { 
    433         draw_guard_pixel(); 
    434         timer=1; 
    435         return 0; 
    436     } 
    437     if(timer==1) { 
    438         int ready; 
    439         static int n=0; 
    440         if (!mrec) ready=1; 
    441         else get_property_case(PROPCASE_SHOOTING, &ready, 4); 
    442         n=draw_guard_pixel(); // will be 0 in PLAY mode, should be 1 or 2 in REC mode. 
    443         if(!ready) return 0; 
    444     } 
    445     ++timer; 
    446     // Try to get the best viewport buffer. In playmode its the _d one, in 
    447     // record mode we try to get the fast live one first 
    448     if (!mrec) { 
    449         img_buf = vid_get_viewport_fb_d(); 
    450     } 
    451     else { 
    452         img_buf = vid_get_viewport_live_fb(); 
    453         if( !img_buf ) { 
    454             img_buf = vid_get_viewport_fb(); 
    455         } 
    456     } 
    457     viewport_height = vid_get_viewport_height(); 
    458     viewport_width = vid_get_viewport_width();  
    459     viewport_image_offset = vid_get_viewport_image_offset();  
    460     viewport_row_offset = vid_get_viewport_row_offset();  
    461         viewport_xoffset = vid_get_viewport_xoffset(); 
    462         viewport_yoffset = vid_get_viewport_yoffset(); 
    463     switch (conf.zebra_mode) { 
    464         case ZEBRA_MODE_ZEBRA_1: 
    465             f = 4; 
    466             break; 
    467         case ZEBRA_MODE_ZEBRA_2: 
    468             f = 8; 
    469             break; 
    470         case ZEBRA_MODE_SOLID: 
    471             f = 1;  
    472             break; 
    473         case ZEBRA_MODE_BLINKED_1: 
    474             f = timer&1;  
    475             break; 
    476         case ZEBRA_MODE_BLINKED_3: 
    477             f = timer&4;  
    478             break; 
    479         case ZEBRA_MODE_BLINKED_2: 
    480         default: 
    481             f = timer&2;  
    482             break; 
    483     } 
    484     // if not in no-zebra phase of blink mode zebra, draw zebra to buf[] 
    485     if (f) { 
    486                 if (viewport_yoffset > 0) { // clear top & bottom areas of buffer if image height if smaller than viewport 
    487                         memset(buf, COLOR_TRANSPARENT, viewport_yoffset*camera_screen.buffer_width); 
    488                         memset(buf+(viewport_yoffset+viewport_height)*camera_screen.buffer_width, COLOR_TRANSPARENT, viewport_yoffset*camera_screen.buffer_width); 
    489                 } 
    490         int step_x, step_v, sy, sx; 
    491         over = 255-conf.zebra_over; 
    492             if (conf.zebra_multichannel) {step_x=2; step_v=6;} else {step_x=1; step_v=3;} 
    493             for (y=viewport_yoffset, v=viewport_image_offset; y<viewport_yoffset+viewport_height; ++y) { 
    494                 sy=y*camera_screen.buffer_width; 
    495                 sx=viewport_xoffset; 
    496                                 if (viewport_xoffset > 0) { // clear left & right areas of buffer if image width if smaller than viewport 
    497                                         memset(buf+sy, COLOR_TRANSPARENT, sx*2); 
    498                                         memset(buf+sy+(sx+viewport_width)*2, COLOR_TRANSPARENT, sx*2); 
    499                                 } 
    500                 for (x=viewport_xoffset; x<viewport_xoffset+viewport_width; x+=step_x, sx+=step_x, v+=step_v) { 
    501                     register int yy, uu, vv; 
    502                     int sel; 
    503                     yy = img_buf[v+1]; 
    504                     s=sy+sx*2; 
    505                     if (conf.zebra_multichannel) { 
    506                         uu = (signed char)img_buf[v]; 
    507                         vv = (signed char)img_buf[v+2]; 
    508                         sel=0; 
    509                         if (!((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) { 
    510                             if (clip8(((yy<<12) +           vv*5743 + 2048)>>12)>over) sel  = 4; // R 
    511                             if (clip8(((yy<<12) - uu*1411 - vv*2925 + 2048)>>12)>over) sel |= 2; // G 
    512                             if (clip8(((yy<<12) + uu*7258           + 2048)>>12)>over) sel |= 1; // B 
    513                         } 
    514                         buf[s]=buf[s+1]=cls[sel]; 
    515                         buf[s+2]=buf[s+3]=cls[sel]; 
    516                     } 
    517                     else if (((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) buf[s]=buf[s+1]=COLOR_TRANSPARENT; 
    518                     else buf[s]=buf[s+1]=(yy>over)?cl_over:(yy<conf.zebra_under)?cl_under:COLOR_TRANSPARENT; 
    519                     if (buf[s] != COLOR_TRANSPARENT && !zebra_drawn) zebra_drawn = 1; 
    520 #if ZEBRA_CANONOSD_BORDER_RESTORE                         
    521                         if(get_cur_buf(s)!=COLOR_TRANSPARENT) buf[s]=get_cur_buf(s);  
    522                         if(conf.zebra_multichannel && get_cur_buf(s+1)!=COLOR_TRANSPARENT) buf[s+1]=get_cur_buf(s+1);  
    523 #else 
    524                         if(cur_buf[s]!=COLOR_TRANSPARENT) buf[s]=cur_buf[s]; 
    525                         if(conf.zebra_multichannel && cur_buf[s+1]!=COLOR_TRANSPARENT) buf[s+1]=cur_buf[s+1]; 
    526 #endif 
    527  
    528                     if (mrec) { 
    529                     } 
    530                                 } 
    531                                 // adjust for cases where buffer is wider than viewport (e.g. on G12) 
    532                                 v += viewport_row_offset; 
    533             } 
    534         if (!zebra_drawn) f=0; 
    535     } 
    536     // if blink mode is in no-zebra phase OR if there was no over/underexposed pixels to draw zebra on 
    537     if (!f) { 
    538         // if zebra was drawn during previous call of this function 
    539         if (need_restore) { 
    540             if (conf.zebra_restore_screen || conf.zebra_restore_osd) { 
    541                 draw_restore(); 
    542             } else {  // clear buf[] of zebra, only leave Canon OSD 
    543                 if (mrec) { // REC mode 
    544 //~ #if ZEBRA_CANONOSD_BORDER_RESTORE 
    545                     //~ // copy rescued Canon OSD to buf[] top/bottom parts and fill center with transparent color: 
    546                     //~ memcpy(buf, cur_buf_top, camera_screen.buffer_width * ZFIX_TOP); 
    547                     //~ memcpy(buf + camera_screen.buffer_size - camera_screen.buffer_width * ZFIX_BOTTOM, cur_buf_bot, camera_screen.buffer_width * ZFIX_BOTTOM); 
    548                     //~ for (s = camera_screen.buffer_width*ZFIX_TOP; s < camera_screen.buffer_size-camera_screen.buffer_width*ZFIX_BOTTOM; s++) { 
    549                         //~ buf[s]=COLOR_TRANSPARENT; 
    550                     //~ } 
    551 //~ #else 
    552                     //~ // copy from a complete Canon OSD rescue screen dump 
    553                     //~ memcpy(buf, cur_buf, camera_screen.buffer_size);  
    554 //~ #endif 
    555                 } else { // Not REC mode 
    556                     // No Canon OSD restore, fill buf[] with transparent color: 
    557                     memset(buf, COLOR_TRANSPARENT, buffer_size); 
    558                 } 
    559                 // draw CHDK osd and histogram to buf[] (if enabled in config) 
    560                 gui_osd_draw_zebra_osd(); 
    561                 // copy buf[] to both display buffers 
    562                  
    563                 if (buf!=scr_buf) 
    564                   memcpy(scr_buf, buf, buffer_size); 
    565                   memcpy(scr_buf+camera_screen.buffer_size, buf, buffer_size); 
    566             } 
    567             need_restore=0; 
    568         } 
    569         return !(conf.zebra_restore_screen && conf.zebra_restore_osd); 
    570     // if zebra was drawn 
    571     } else { 
    572         // draw CHDK osd and histogram to buf[] over zebra (if enabled in config)             
    573         gui_osd_draw_zebra_osd(); 
    574         // copy buf[] to both display buffers    
    575         if (buf!=scr_buf) 
    576             memcpy(scr_buf, buf, buffer_size); 
    577             memcpy(scr_buf+camera_screen.buffer_size, buf, buffer_size); 
    578  
    579         need_restore=1; 
    580         return 1; 
    581     } 
    582     return 0; 
    583 } 
    584 #else 
    585 //------------------------------------------------------------------- 
    586 int gui_osd_draw_zebra(int show) { 
    587     unsigned int v, s, x, y, f, over; 
    588     color cl_under=conf.zebra_color>>8, cl_over=conf.zebra_color&0xFF; 
    589     static int need_restore=0; 
    590     int viewport_height; 
    591     int mrec = ((mode_get()&MODE_MASK) == MODE_REC); 
    592     int zebra_drawn=0; 
    593     color cls[] = { 
    594         COLOR_TRANSPARENT, 
    595         (mrec)?COLOR_HISTO_B:COLOR_HISTO_B_PLAY, 
    596         (mrec)?COLOR_HISTO_G:COLOR_HISTO_G_PLAY, 
    597         (mrec)?COLOR_HISTO_BG:COLOR_HISTO_BG_PLAY, 
    598         (mrec)?COLOR_HISTO_R:COLOR_HISTO_R_PLAY, 
    599         (mrec)?COLOR_HISTO_RB:COLOR_HISTO_RB_PLAY, 
    600         (mrec)?COLOR_HISTO_RG:COLOR_HISTO_RG_PLAY, 
    601         COLOR_BLACK 
    602     }; 
    603          
    604     unsigned bWide = 1; // if wide (16:9) or standard (4:3) aspect ratio (but 1 in cameras that only have 4:3) 
    605     unsigned aspOffset = 0; // offset to add to x-coord (or buffer address) when drawing zebra 
    606  
    607 #if CAM_HAS_VARIABLE_ASPECT 
    608     if (shooting_get_prop(PROPCASE_ASPECT_RATIO) == 0) // standard requires x-shift to overlay drawing 
    609     { 
    610         bWide = 0; 
    611         //aspOffset = (camera_screen.width - (camera_screen.width * 12 / 16)) / 2; // = actual calculation, simplified below 
    612         aspOffset = camera_screen.width / 8; // half of the difference in width between equal height 16:9 and 4:3 screens, = black bar width 
    613     } 
    614 #endif 
    615          
    616     if (!gui_osd_zebra_init(show)) 
    617         return 0; 
    618  
    619     if(timer==0) { 
    620         draw_guard_pixel(); 
    621         timer=1; 
    622         return 0; 
    623     } 
    624     if(timer==1) { 
    625         int ready; 
    626         static int n=0; 
    627         if (!mrec) ready=1; 
    628         else get_property_case(PROPCASE_SHOOTING, &ready, 4); 
    629         n=draw_guard_pixel(); // will be 0 in PLAY mode, should be 1 or 2 in REC mode. 
    630         if(!ready) return 0; 
    631 #if ZEBRA_CANONOSD_BORDER_RESTORE 
    632         // rescue Canon OSD from scr_buf to cur_buf_top and _bot: 
    633         if (n==1) { 
    634             memcpy(cur_buf_top, scr_buf, camera_screen.buffer_width*ZFIX_TOP); 
    635             memcpy(cur_buf_bot, scr_buf + camera_screen.buffer_size - camera_screen.buffer_width*ZFIX_BOTTOM, camera_screen.buffer_width*ZFIX_BOTTOM); 
    636         } 
    637         else { 
    638             memcpy(cur_buf_top, scr_buf + camera_screen.buffer_size, camera_screen.buffer_width*ZFIX_TOP); 
    639             memcpy(cur_buf_bot, scr_buf + 2*camera_screen.buffer_size - camera_screen.buffer_width*ZFIX_BOTTOM, camera_screen.buffer_width*ZFIX_BOTTOM); 
    640         } 
    641 #else 
    642         // rescue Canon OSD from cur_buf 
    643         if(n==1) memcpy(cur_buf, scr_buf, camera_screen.buffer_size); 
    644         else memcpy(cur_buf, scr_buf+camera_screen.buffer_size, camera_screen.buffer_size); 
    645 #endif 
    646     } 
    647     ++timer; 
    648     // Try to get the best viewport buffer. In playmode its the _d one, in 
    649     // record mode we try to get the fast live one first 
    650     if (!mrec) { 
    651         img_buf = vid_get_viewport_fb_d(); 
    652     } 
    653     else { 
    654         img_buf = vid_get_viewport_live_fb(); 
    655         if( !img_buf ) { 
    656             img_buf = vid_get_viewport_fb(); 
    657         } 
    658     } 
    659     viewport_height = vid_get_viewport_height(); 
    660     switch (conf.zebra_mode) { 
    661         case ZEBRA_MODE_ZEBRA_1: 
    662             f = 4; 
    663             break; 
    664         case ZEBRA_MODE_ZEBRA_2: 
    665             f = 8; 
    666             break; 
    667         case ZEBRA_MODE_SOLID: 
    668             f = 1;  
    669             break; 
    670         case ZEBRA_MODE_BLINKED_1: 
    671             f = timer&1;  
    672             break; 
    673         case ZEBRA_MODE_BLINKED_3: 
    674             f = timer&4;  
    675             break; 
    676         case ZEBRA_MODE_BLINKED_2: 
    677         default: 
    678             f = timer&2;  
    679             break; 
    680     } 
    681     // if not in no-zebra phase of blink mode zebra, draw zebra to buf[] 
    682     if (f) { 
    683         int step_x, step_v; 
    684         over = 255-conf.zebra_over; 
    685             if (conf.zebra_multichannel) {step_x=2; step_v=6;} else {step_x=1; step_v=3;} 
    686             s = aspOffset; 
    687             for (y=1, v=0; y<=viewport_height; ++y) { 
    688                 for (x=0; x<camera_screen.width; x+=step_x, s+=step_x, v+=step_v) { 
    689                     register int yy, uu, vv; 
    690                     int sel; 
    691                                                                                  
    692                     if (!bWide && (x + aspOffset >= camera_screen.width - aspOffset)) continue; // do not draw "outside screen"  
    693                                                                                  
    694                     yy = img_buf[v+1]; 
    695                     if (conf.zebra_multichannel) { 
    696                         uu = (signed char)img_buf[v]; 
    697                         vv = (signed char)img_buf[v+2]; 
    698                         sel=0; 
    699                         if (!((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) { 
    700                             if (clip8(((yy<<12) +           vv*5743 + 2048)>>12)>over) sel  = 4; // R 
    701                             if (clip8(((yy<<12) - uu*1411 - vv*2925 + 2048)>>12)>over) sel |= 2; // G 
    702                             if (clip8(((yy<<12) + uu*7258           + 2048)>>12)>over) sel |= 1; // B 
    703                         } 
    704                         buf[s]=buf[s+1]=cls[sel]; 
    705                     } 
    706                     else if (((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) buf[s]=COLOR_TRANSPARENT; 
    707                     else buf[s]=(yy>over)?cl_over:(yy<conf.zebra_under)?cl_under:COLOR_TRANSPARENT; 
    708                     if (buf[s] != COLOR_TRANSPARENT && !zebra_drawn) zebra_drawn = 1; 
    709                     if (mrec) { 
    710                         // draw Canon OSD to buf[] if in REC mode 
    711 #if ZEBRA_CANONOSD_BORDER_RESTORE                         
    712                         if(get_cur_buf(s)!=COLOR_TRANSPARENT) buf[s]=get_cur_buf(s);  
    713                         if(conf.zebra_multichannel && get_cur_buf(s+1)!=COLOR_TRANSPARENT) buf[s+1]=get_cur_buf(s+1);  
    714 #else 
    715                         if(cur_buf[s]!=COLOR_TRANSPARENT) buf[s]=cur_buf[s]; 
    716                         if(conf.zebra_multichannel && cur_buf[s+1]!=COLOR_TRANSPARENT) buf[s+1]=cur_buf[s+1]; 
    717 #endif 
    718                     } 
    719                 } 
    720                 s+=camera_screen.buffer_width-camera_screen.width; 
    721                 if (y*camera_screen.height/viewport_height == (s+camera_screen.buffer_width)/camera_screen.buffer_width) { 
    722                     memcpy(buf+s, buf+s-camera_screen.buffer_width, camera_screen.buffer_width); 
    723                     s+=camera_screen.buffer_width; 
    724                 } 
    725             } 
    726         if (!zebra_drawn) f=0; 
    727     } 
    728     // if blink mode is in no-zebra phase OR if there was no over/underexposed pixels to draw zebra on 
    729     if (!f) { 
    730         // if zebra was drawn during previous call of this function 
    731         if (need_restore) { 
    732             if (conf.zebra_restore_screen || conf.zebra_restore_osd) { 
    733                 draw_restore(); 
    734             } else {  // clear buf[] of zebra, only leave Canon OSD 
    735                 if (mrec) { // REC mode 
    736 #if ZEBRA_CANONOSD_BORDER_RESTORE 
    737                     // copy rescued Canon OSD to buf[] top/bottom parts and fill center with transparent color: 
    738                     memcpy(buf, cur_buf_top, camera_screen.buffer_width * ZFIX_TOP); 
    739                     memcpy(buf + camera_screen.buffer_size - camera_screen.buffer_width * ZFIX_BOTTOM, cur_buf_bot, camera_screen.buffer_width * ZFIX_BOTTOM); 
    740                     for (s = camera_screen.buffer_width*ZFIX_TOP; s < camera_screen.buffer_size-camera_screen.buffer_width*ZFIX_BOTTOM; s++) { 
    741                         buf[s]=COLOR_TRANSPARENT; 
    742                     } 
    743 #else 
    744                     // copy from a complete Canon OSD rescue screen dump 
    745                     memcpy(buf, cur_buf, camera_screen.buffer_size);  
    746 #endif 
    747                 } else { // Not REC mode 
    748                     // No Canon OSD restore, fill buf[] with transparent color: 
    749                     memset(buf, COLOR_TRANSPARENT, camera_screen.buffer_size); 
    750                 } 
    751                 // draw CHDK osd and histogram to buf[] (if enabled in config) 
    752                 gui_osd_draw_zebra_osd(); 
    753                 // copy buf[] to both display buffers 
    754                 memcpy(scr_buf, buf, camera_screen.buffer_size); 
    755                 memcpy(scr_buf+camera_screen.buffer_size, buf, camera_screen.buffer_size); 
    756             } 
    757             need_restore=0; 
    758         } 
    759         return !(conf.zebra_restore_screen && conf.zebra_restore_osd); 
    760     // if zebra was drawn 
    761     } else { 
    762         // draw CHDK osd and histogram to buf[] over zebra (if enabled in config)             
    763         gui_osd_draw_zebra_osd(); 
    764         // copy buf[] to both display buffers           
    765         memcpy(scr_buf, buf, camera_screen.buffer_size); 
    766         memcpy(scr_buf+camera_screen.buffer_size, buf, camera_screen.buffer_size); 
    767  
    768         need_restore=1; 
    769         return 1; 
    770     } 
    771     return 0; 
    772 } 
    773 #endif 
     205    if (conf.histo_show_ev_grid) for (i=1;i<=4;i++) draw_line(x+(1+w)*i/5, y, x+(1+w)*i/5, y+h, FG_COLOR(conf.histo_color2)); 
     206} 
     207 
    774208//------------------------------------------------------------------- 
    775209static void gui_osd_draw_blended_histo(coord x, coord y) { 
     
    777211    int m = ((mode_get()&MODE_MASK) == MODE_REC); 
    778212    color cls[] = { 
    779         conf.histo_color>>8, 
     213        BG_COLOR(conf.histo_color), 
    780214        (m)?COLOR_HISTO_B:COLOR_HISTO_B_PLAY, 
    781215        (m)?COLOR_HISTO_G:COLOR_HISTO_G_PLAY, 
     
    803237    } 
    804238 
    805     draw_rect(x, y, x+1+HISTO_WIDTH, y+HISTO_HEIGHT, conf.histo_color2&0xFF); 
     239    draw_rect(x, y, x+1+HISTO_WIDTH, y+HISTO_HEIGHT, FG_COLOR(conf.histo_color2)); 
    806240    //Vertical lines 
    807     if (conf.histo_show_ev_grid) for (i=1;i<=4;i++) draw_line(x+(1+HISTO_WIDTH)*i/5, y, x+(1+HISTO_WIDTH)*i/5, y+HISTO_HEIGHT, conf.histo_color2&0xFF); 
     241    if (conf.histo_show_ev_grid) for (i=1;i<=4;i++) draw_line(x+(1+HISTO_WIDTH)*i/5, y, x+(1+HISTO_WIDTH)*i/5, y+HISTO_HEIGHT, FG_COLOR(conf.histo_color2)); 
    808242 
    809243} 
     
    853287    if (conf.histo_layout != OSD_HISTO_LAYOUT_R_G_B) { 
    854288        if (under_exposed && conf.show_overexp) { 
    855             draw_filled_ellipse(conf.histo_pos.x+5, conf.histo_pos.y+5, 3, 3, MAKE_COLOR(conf.histo_color2>>8, conf.histo_color2>>8)); 
     289            draw_filled_ellipse(conf.histo_pos.x+5, conf.histo_pos.y+5, 3, 3, MAKE_COLOR(BG_COLOR(conf.histo_color2), BG_COLOR(conf.histo_color2))); 
    856290        } 
    857291 
    858292        if (over_exposed && conf.show_overexp) { 
    859             draw_filled_ellipse(conf.histo_pos.x+HISTO_WIDTH-5, conf.histo_pos.y+5, 3, 3, MAKE_COLOR(conf.histo_color2>>8, conf.histo_color2>>8)); 
     293            draw_filled_ellipse(conf.histo_pos.x+HISTO_WIDTH-5, conf.histo_pos.y+5, 3, 3, MAKE_COLOR(BG_COLOR(conf.histo_color2), BG_COLOR(conf.histo_color2))); 
    860294        } 
    861295    } 
     
    1515949 int i, deltax; 
    1516950 
    1517  draw_filled_rect(x0,y0,x0+70,y0+24, visible? ((conf.osd_color&0xFF00))|(conf.osd_color>>8): COLOR_TRANSPARENT); 
     951 draw_filled_rect(x0,y0,x0+70,y0+24, visible? MAKE_COLOR(BG_COLOR(conf.osd_color),BG_COLOR(conf.osd_color)): COLOR_TRANSPARENT); 
    1518952 
    1519953 if (!visible) { return; } 
  • trunk/core/gui_osd.h

    r1527 r1569  
    1212#define OSD_HISTO_LAYOUT_BLEND          6 
    1313#define OSD_HISTO_LAYOUT_BLEND_Y        7 
    14  
    15 #define ZEBRA_DRAW_NONE                 0 
    16 #define ZEBRA_DRAW_HISTO                1 
    17 #define ZEBRA_DRAW_OSD                  2 
    1814 
    1915#define ZOOM_SHOW_X                     0 
  • trunk/core/gui_palette.c

    r1527 r1569  
    9696        for (y=DISP_TOP; y<DISP_BOTTOM; y+=CELL_SIZE) 
    9797        { 
    98             for (x=DISP_LEFT; x<DISP_RIGHT; x+=CELL_SIZE, c+=0x0100) 
     98            for (x=DISP_LEFT; x<DISP_RIGHT; x+=CELL_SIZE, c+=MAKE_COLOR(1,0)) 
    9999            { 
    100100                draw_filled_rect(xl+x, y, xl+x+CELL_SIZE, y+CELL_SIZE, c); 
     
    146146// RETURN VALUE: 1 error, 0 ok 
    147147//--------------------------------------------------------- 
    148 int _module_loader( void** chdk_export_list ) 
     148int _module_loader( unsigned int* chdk_export_list ) 
    149149{ 
    150   if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     150  if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    151151     return 1; 
    152152  if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) ) 
     
    185185 
    186186  if ( argn==3 ) 
    187   gui_palette_init( arguments[0], (color)arguments[1], (void*)arguments[2]); 
     187    gui_palette_init( arguments[0], (color)arguments[1], (void*)arguments[2]); 
    188188  else 
    189189        gui_palette_init( PALETTE_MODE_DEFAULT, 0x00, NULL ); 
  • trunk/core/gui_palette.h

    r1527 r1569  
    1010 
    1111//------------------------------------------------------------------- 
    12 extern void gui_palette_init(int mode, color st_color, void (*on_select)(color clr)); 
     12extern void module_palette_run(int mode, color st_color, void (*on_select)(color clr)); 
    1313 
    1414//------------------------------------------------------------------- 
  • trunk/core/gui_read.c

    r1527 r1569  
    99#include "gui_batt.h" 
    1010#include "gui_read.h" 
    11  
    12  
     11#include "gui_menu.h" 
     12#include "gui_lang.h" 
     13 
     14#include "modules.h" 
    1315#include "module_load.h" 
     16 
     17//------------------------------------------------------------------- 
     18 
     19typedef struct 
     20{ 
     21    color reader_color; 
     22    char reader_file[100]; 
     23    int  reader_pos; 
     24    int  reader_autoscroll; 
     25    int  reader_autoscroll_delay; 
     26    char reader_rbf_file[100]; 
     27    int  reader_codepage; 
     28    int  reader_wrap_by_words; 
     29} ReadConf; 
     30 
     31ReadConf rconf; 
     32 
     33static ConfInfo conf_info[] = { 
     34    CONF_INFO( 1, rconf.reader_color,           CONF_DEF_VALUE, cl:0, NULL), 
     35    CONF_INFO( 2, rconf.reader_file,            CONF_CHAR_PTR,   ptr:"A/CHDK/BOOKS/README.TXT", NULL), 
     36    CONF_INFO( 3, rconf.reader_pos,             CONF_DEF_VALUE, i:0, NULL), 
     37    CONF_INFO( 4, rconf.reader_autoscroll,      CONF_DEF_VALUE, i:0, NULL), 
     38    CONF_INFO( 5, rconf.reader_autoscroll_delay,CONF_DEF_VALUE, i:5, NULL), 
     39    CONF_INFO( 6, rconf.reader_rbf_file,        CONF_CHAR_PTR,   ptr:"", NULL), 
     40    CONF_INFO( 7, rconf.reader_codepage,        CONF_DEF_VALUE, i:FONT_CP_WIN, NULL), 
     41    CONF_INFO( 8, rconf.reader_wrap_by_words,   CONF_DEF_VALUE, i:1, NULL), 
     42}; 
     43 
     44//------------------------------------------------------------------- 
    1445 
    1546extern void gui_read_kbd_process_menu_btn(); 
     
    1748void gui_read_draw(int enforce_redraw); 
    1849void gui_read_kbd_leave(); 
    19  
    20 int *conf_reader_autoscroll; 
    21 int *conf_reader_autoscroll_delay; 
    22 int *conf_reader_pos; 
    23 int *conf_reader_wrap_by_words; 
    24 color *conf_reader_color; 
    25 char *conf_reader_file; 
    26 char *conf_menu_rbf_file; 
    2750 
    2851gui_handler GUI_MODE_READ =  
     
    6386//------------------------------------------------------------------- 
    6487static void gui_read_draw_scroll_indicator() { 
    65     draw_txt_char((camera_screen.width-camera_screen.ts_button_border)/FONT_WIDTH-2, 0, (*conf_reader_autoscroll)?((pause)?'\x05':'\x04'):'\x03', MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline 
     88    draw_txt_char((camera_screen.width-camera_screen.ts_button_border)/FONT_WIDTH-2, 0, (rconf.reader_autoscroll)?((pause)?'\x05':'\x04'):'\x03', MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline 
    6689} 
    6790 
     
    7093    static struct STD_stat   st; 
    7194    read_file = safe_open(file, O_RDONLY, 0777); 
    72     if (strcmp(file, conf_reader_file)!=0) { 
    73         *conf_reader_pos = 0; 
    74         strcpy(conf_reader_file, file); 
     95    if (strcmp(file, rconf.reader_file)!=0) { 
     96        rconf.reader_pos = 0; 
     97        strcpy(rconf.reader_file, file); 
    7598    } 
    7699    read_on_screen = 0; 
    77100    read_file_size = (read_file>=0 && safe_stat((char*)file, &st)==0)?st.st_size:0; 
    78     if (read_file_size<=*conf_reader_pos) { 
    79         *conf_reader_pos = 0; 
     101    if (read_file_size<=rconf.reader_pos) { 
     102        rconf.reader_pos = 0; 
    80103    } 
    81104    pause = 0; 
     
    88111     
    89112        reader_is_active=1;     
    90     gui_set_mode(&GUI_MODE_READ); 
     113    //gui_set_mode(&GUI_MODE_READ); 
    91114 
    92115    draw_filled_rect(0, 0, camera_screen.width-1, y-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 
    93     draw_filled_rect(0, y, camera_screen.width-1, camera_screen.height-1, MAKE_COLOR((*conf_reader_color>>8)&0xFF, (*conf_reader_color>>8)&0xFF)); 
     116    draw_filled_rect(0, y, camera_screen.width-1, camera_screen.height-1, MAKE_COLOR(BG_COLOR(rconf.reader_color), BG_COLOR(rconf.reader_color))); 
    94117 
    95118    gui_read_draw_scroll_indicator(); 
     
    101124//------------------------------------------------------------------- 
    102125static void read_goto_next_line() { 
    103     draw_filled_rect(xx, yy, x+w-1, yy+rbf_font_height()-1, MAKE_COLOR(*conf_reader_color>>8, *conf_reader_color>>8)); 
     126    draw_filled_rect(xx, yy, x+w-1, yy+rbf_font_height()-1, MAKE_COLOR(BG_COLOR(rconf.reader_color), BG_COLOR(rconf.reader_color))); 
    104127    xx  = x; 
    105128    yy += rbf_font_height(); 
     
    113136//------------------------------------------------------------------- 
    114137void gui_read_draw(int enforce_redraw) { 
    115     if (*conf_reader_autoscroll && !pause && get_tick_count()-last_time >= *conf_reader_autoscroll_delay*1000 && (*conf_reader_pos+read_on_screen)<read_file_size) { 
    116         *conf_reader_pos += read_on_screen; 
     138    if (rconf.reader_autoscroll && !pause && get_tick_count()-last_time >= rconf.reader_autoscroll_delay*1000 && (rconf.reader_pos+read_on_screen)<read_file_size) { 
     139        rconf.reader_pos += read_on_screen; 
    117140        read_to_draw = 1; 
    118141    } 
     
    122145        xx=x; yy=y; 
    123146 
    124         lseek(read_file, *conf_reader_pos, SEEK_SET); 
     147        lseek(read_file, rconf.reader_pos, SEEK_SET); 
    125148        read_on_screen=0; 
    126149 
     
    130153                 read_goto_next_line(); 
    131154                 if (yy < y+h) 
    132                      draw_filled_rect(x, yy, x+w-1, y+h-1, MAKE_COLOR(*conf_reader_color>>8, *conf_reader_color>>8)); 
     155                     draw_filled_rect(x, yy, x+w-1, y+h-1, MAKE_COLOR(BG_COLOR(rconf.reader_color), BG_COLOR(rconf.reader_color))); 
    133156                 break; 
    134157            } 
     
    147170                        // no break here 
    148171                    default: 
    149                         if (*conf_reader_wrap_by_words) { 
     172                        if (rconf.reader_wrap_by_words) { 
    150173                            if (buffer[i] == ' ') { 
    151174                                new_word = 1; 
     
    177200                            continue; 
    178201                        } 
    179                         xx+=rbf_draw_char(xx, yy, buffer[i], *conf_reader_color); 
     202                        xx+=rbf_draw_char(xx, yy, buffer[i], rconf.reader_color); 
    180203                        break; 
    181204                } 
     
    189212        } 
    190213     
    191         sprintf(buffer, "(%3d%%) %d/%d  ", (read_file_size)?(*conf_reader_pos*100/read_file_size):0, *conf_reader_pos, read_file_size); 
     214        sprintf(buffer, "(%3d%%) %d/%d  ", (read_file_size)?(rconf.reader_pos*100/read_file_size):0, rconf.reader_pos, read_file_size); 
    192215        buffer[camera_screen.width/FONT_WIDTH]=0; 
    193216        draw_txt_string((camera_screen.ts_button_border/FONT_WIDTH), 0, buffer, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline 
     
    198221            n=i*read_on_screen/read_file_size;           // bar height 
    199222            if (n<20) n=20; 
    200             i=(i-n)**conf_reader_pos/read_file_size;   // top pos 
     223            i=(i-n)*rconf.reader_pos/read_file_size;   // top pos 
    201224            draw_filled_rect(x+w+6+2, y+1,   x+w+6+6, y+1+i,   MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 
    202225            draw_filled_rect(x+w+6+2, y+i+n, x+w+6+6, y+h-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 
     
    221244        case KEY_UP: 
    222245        case KEY_LEFT: 
    223             if (*conf_reader_pos>0) { 
    224                 *conf_reader_pos -= 45*15; 
    225                 if (*conf_reader_pos<0) *conf_reader_pos=0; 
     246            if (rconf.reader_pos>0) { 
     247                rconf.reader_pos -= 45*15; 
     248                if (rconf.reader_pos<0) rconf.reader_pos=0; 
    226249                read_to_draw = 1; 
    227250            } 
     
    232255        case KEY_RIGHT: 
    233256        case KEY_SHOOT_HALF: 
    234             if ((*conf_reader_pos+read_on_screen)<read_file_size) { 
    235                 *conf_reader_pos += read_on_screen; 
     257            if ((rconf.reader_pos+read_on_screen)<read_file_size) { 
     258                rconf.reader_pos += read_on_screen; 
    236259                read_to_draw = 1; 
    237260            } 
     
    250273} 
    251274 
    252 extern int module_idx; 
    253  
    254275//------------------------------------------------------------------- 
    255276// Menu button handled for text reader 
     
    258279    gui_read_kbd_process(); 
    259280    gui_default_kbd_process_menu_btn(); 
    260         module_async_unload(module_idx); 
    261281} 
    262282 
     
    267287 
    268288    reader_is_active = 0; 
    269     if (!rbf_load(conf_menu_rbf_file)) 
     289    if (!rbf_load(conf.menu_rbf_file)) 
    270290        rbf_load_from_8x16(current_font); 
    271291    rbf_set_codepage(FONT_CP_WIN); 
     
    276296} 
    277297 
     298//------------------------------------------------------------------- 
     299static void gui_draw_read_selected(const char *fn) { 
     300    if (fn) { 
     301        if (!rbf_load(rconf.reader_rbf_file)) 
     302            rbf_load_from_8x16(current_font); 
     303        rbf_set_codepage(rconf.reader_codepage); 
     304        gui_set_mode(&GUI_MODE_READ); 
     305        gui_read_init(fn); 
     306 
     307                //unsigned int argv[] ={ (unsigned int)fn }; 
     308                //module_run("txtread.flt", 0, sizeof(argv)/sizeof(argv[0]), argv, UNLOAD_IF_ERR); 
     309    } 
     310} 
     311 
     312void gui_draw_read(int arg) { 
     313    module_fselect_init_w_mode(LANG_STR_SELECT_TEXT_FILE, rconf.reader_file, "A/CHDK/BOOKS", gui_draw_read_selected, 1); 
     314    void gui_fselect_set_key_redraw(int n); 
     315    //gui_fselect_set_key_redraw(1);    @tsv 
     316} 
     317 
     318void gui_draw_read_last(int arg) { 
     319    struct STD_stat st; 
     320    if (safe_stat(rconf.reader_file,&st) == 0) { 
     321        gui_draw_read_selected(rconf.reader_file); 
     322    } else { 
     323        gui_draw_read(arg); 
     324    } 
     325} 
     326 
     327static void gui_draw_rbf_selected(const char *fn) { 
     328    if (fn) { 
     329        strcpy(rconf.reader_rbf_file, fn); 
     330    } 
     331} 
     332 
     333void gui_draw_load_rbf(int arg) { 
     334    module_fselect_init(LANG_STR_SELECT_FONT_FILE, rconf.reader_rbf_file, "A/CHDK/FONTS", gui_draw_rbf_selected); 
     335} 
     336 
     337static const char* gui_reader_codepage_cps[] = { "Win1251", "DOS"}; 
     338static CMenuItem reader_submenu_items[] = { 
     339    MENU_ITEM(0x35,LANG_MENU_READ_OPEN_NEW,           MENUITEM_PROC,    gui_draw_read, 0 ), 
     340    MENU_ITEM(0x35,LANG_MENU_READ_OPEN_LAST,          MENUITEM_PROC,    gui_draw_read_last, 0 ), 
     341    MENU_ITEM(0x35,LANG_MENU_READ_SELECT_FONT,        MENUITEM_PROC,    gui_draw_load_rbf, 0 ), 
     342    MENU_ENUM2(0x5f,LANG_MENU_READ_CODEPAGE,          &rconf.reader_codepage, gui_reader_codepage_cps ), 
     343    MENU_ITEM(0x5c,LANG_MENU_READ_WORD_WRAP,          MENUITEM_BOOL,    &rconf.reader_wrap_by_words, 0 ), 
     344    MENU_ITEM(0x5c,LANG_MENU_READ_AUTOSCROLL,         MENUITEM_BOOL,    &rconf.reader_autoscroll, 0 ), 
     345    MENU_ITEM(0x5f,LANG_MENU_READ_AUTOSCROLL_DELAY,   MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &rconf.reader_autoscroll_delay, MENU_MINMAX(0, 60) ), 
     346    MENU_ITEM(0x65,LANG_MENU_VIS_READER_TEXT,         MENUITEM_COLOR_FG,  &rconf.reader_color, 0 ), 
     347    MENU_ITEM(0x65,LANG_MENU_VIS_READER_BKG,          MENUITEM_COLOR_BG,  &rconf.reader_color, 0 ), 
     348    MENU_ITEM(0x51,LANG_MENU_BACK,                    MENUITEM_UP, 0, 0 ), 
     349    {0} 
     350}; 
     351static CMenu reader_submenu = {0x37,LANG_MENU_READ_TITLE, NULL, reader_submenu_items }; 
     352 
    278353// =========  MODULE INIT ================= 
    279354#include "module_load.h" 
     
    296371// RETURN VALUE: 1 error, 0 ok 
    297372//--------------------------------------------------------- 
    298 int _module_loader( void** chdk_export_list ) 
    299 { 
    300   if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     373int _module_loader( unsigned int* chdk_export_list ) 
     374{ 
     375  if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    301376     return 1; 
     377 
    302378  if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) ) 
    303379          return 1; 
    304  
    305   tConfigVal configVal; 
    306   CONF_BIND_COLOR( 31, conf_reader_color          ); 
    307   CONF_BIND_STR( 38, conf_reader_file             ); 
    308   CONF_BIND_INT( 39, conf_reader_pos              ); 
    309   CONF_BIND_INT( 43, conf_reader_autoscroll       ); 
    310   CONF_BIND_INT( 44, conf_reader_autoscroll_delay ); 
    311   CONF_BIND_INT( 61, conf_reader_wrap_by_words    ); 
    312   CONF_BIND_STR( 66, conf_menu_rbf_file           ); 
     380  if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 
     381         return 1; 
     382 
     383  conf_info[0].cl = MAKE_COLOR(COLOR_GREY, COLOR_WHITE); 
     384  config_restore(&conf_info[0], "A/CHDK/MODULES/CFG/txtread.cfg", sizeof(conf_info)/sizeof(conf_info[0]), 0, 0); 
    313385 
    314386  return 0; 
     
    323395int _module_unloader() 
    324396{ 
    325   // We should make "leave sequence" to restore font settings 
    326   gui_read_kbd_leave(); 
    327  
    328   GUI_MODE_READ.magicnum = 0;   //sanity clean to prevent accidentaly assign/restore guimode to unloaded module  
    329  
    330   return 0; 
     397    config_save(&conf_info[0], "A/CHDK/MODULES/CFG/txtread.cfg", sizeof(conf_info)/sizeof(conf_info[0])); 
     398     
     399    GUI_MODE_READ.magicnum = 0; //sanity clean to prevent accidentaly assign/restore guimode to unloaded module  
     400 
     401    return 0; 
    331402} 
    332403 
     
    340411  module_idx=moduleidx; 
    341412 
    342   if ( argn!=1 || arguments[0]==0) { 
    343         module_async_unload(moduleidx); 
    344     return 1; 
    345   } 
    346  
    347   char* fn=(char*)arguments[0]; 
    348   gui_read_init(fn); 
     413  gui_activate_sub_menu(&reader_submenu, module_idx); 
    349414 
    350415  return 0; 
  • trunk/core/gui_reversi.c

    r1527 r1569  
    99#include "gui_batt.h" 
    1010#include "gui_mbox.h" 
    11 #include "gui_reversi.h" 
    1211 
    1312#include "module_load.h" 
  • trunk/core/gui_snake.c

    r1527 r1569  
    429429} 
    430430 
     431int basic_module_init() { 
     432  return gui_snake_init(); 
     433} 
     434 
    431435extern int module_idx; 
    432436void gui_module_menu_kbd_process() { 
    433437        gui_default_kbd_process_menu_btn(); 
    434438        module_async_unload(module_idx); 
    435 } 
    436  
    437  
    438 // =========  MODULE INIT ================= 
    439 #include "module_load.h" 
    440 int module_idx=-1; 
    441  
    442 /***************** BEGIN OF AUXILARY PART ********************* 
    443   ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
    444  **************************************************************/ 
    445  
    446 void* MODULE_EXPORT_LIST[] = { 
    447         /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
    448         /* 1 */ (void*)0 
    449                 }; 
    450  
    451  
    452 //--------------------------------------------------------- 
    453 // PURPOSE:   Bind module symbols with chdk.  
    454 //              Required function 
    455 // PARAMETERS: pointer to chdk list of export 
    456 // RETURN VALUE: 1 error, 0 ok 
    457 //--------------------------------------------------------- 
    458 int _module_loader( void** chdk_export_list ) 
    459 { 
    460   if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    461      return 1; 
    462   if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) ) 
    463           return 1; 
    464  
    465   return 0; 
    466 } 
    467  
    468  
    469  
    470 //--------------------------------------------------------- 
    471 // PURPOSE: Finalize module operations (close allocs, etc) 
    472 // RETURN VALUE: 0-ok, 1-fail 
    473 //--------------------------------------------------------- 
    474 int _module_unloader() 
    475 { 
    476   return 0; 
    477 } 
    478  
    479  
    480 //--------------------------------------------------------- 
    481 // PURPOSE: Default action for simple modules (direct run) 
    482 // NOTE: Please comment this function if no default action and this library module 
    483 //--------------------------------------------------------- 
    484 int _module_run(int moduleidx, int argn, int* arguments) 
    485 { 
    486   module_idx=moduleidx; 
    487  
    488   int rv = gui_snake_init(); 
    489   if ( ! rv ) 
    490         module_async_unload(moduleidx);         // fail to init - "unload me" 
    491  
    492   return 0; 
    493439} 
    494440 
  • trunk/core/gui_sokoban.c

    r1527 r1569  
    1010#include "gui_batt.h" 
    1111#include "gui_mbox.h" 
    12 #include "gui_sokoban.h" 
    1312 
    1413#include "module_load.h" 
     14 
     15//------------------------------------------------------------------- 
     16 
     17typedef struct 
     18{ 
     19    int sokoban_level; 
     20} SokobanConf; 
     21 
     22SokobanConf sconf; 
     23 
     24static const ConfInfo conf_info[] = { 
     25    CONF_INFO( 1, sconf.sokoban_level,          CONF_DEF_VALUE, i:0, NULL), 
     26}; 
    1527 
    1628void gui_module_menu_kbd_process(); 
     
    1830void gui_sokoban_draw(int enforce_redraw); 
    1931 
    20 int *conf_sokoban_level; 
    21  
    2232gui_handler GUI_MODE_SOKOBAN =  
    2333    /*GUI_MODE_SOKOBAN*/    { GUI_MODE_MODULE,   gui_sokoban_draw,     gui_sokoban_kbd_process,    gui_module_menu_kbd_process, GUI_MODE_FLAG_NODRAWRESTORE, GUI_MODE_MAGICNUM }; 
    24  
    2534 
    2635//------------------------------------------------------------------- 
     
    209218     
    210219    free(buf); 
    211     *conf_sokoban_level = lvl; 
     220    sconf.sokoban_level = lvl; 
    212221    moves = 0; 
    213222    sokoban_undo_reset(); 
     
    227236//------------------------------------------------------------------- 
    228237static void sokoban_next_level() { 
    229     if (++*conf_sokoban_level >= num_levels) *conf_sokoban_level = 0; 
    230     sokoban_set_level(*conf_sokoban_level); 
     238    if (++sconf.sokoban_level >= num_levels) sconf.sokoban_level = 0; 
     239    sokoban_set_level(sconf.sokoban_level); 
    231240    need_redraw_all = 1; 
    232241} 
     
    325334        return 0; 
    326335    } 
    327     else if(*conf_sokoban_level >= num_levels) { 
    328         *conf_sokoban_level = 0; 
     336    else if(sconf.sokoban_level >= num_levels) { 
     337        sconf.sokoban_level = 0; 
    329338    } 
    330339    cell_size = camera_screen.height/FIELD_HEIGHT; 
    331     sokoban_set_level(*conf_sokoban_level); 
     340    sokoban_set_level(sconf.sokoban_level); 
    332341        // if the file is no longer readable, set_level will set this 
    333342    if(!num_levels) { 
     
    374383        case KEY_ERASE: 
    375384        case KEY_DISPLAY: 
    376             sokoban_set_level(*conf_sokoban_level); 
     385            sokoban_set_level(sconf.sokoban_level); 
    377386            need_redraw_all = 1; 
    378387            break; 
     
    425434        draw_line(camera_screen.ts_button_border+cell_size*FIELD_WIDTH+1, 0, camera_screen.ts_button_border+cell_size*FIELD_WIDTH+1, camera_screen.height-1, COLOR_BLACK); 
    426435 
    427         sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_LEVEL), *conf_sokoban_level+1); 
     436        sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_LEVEL), sconf.sokoban_level+1); 
    428437        draw_string(camera_screen.ts_button_border+cell_size*FIELD_WIDTH+2, 8, str, MAKE_COLOR(SCREEN_COLOR, COLOR_WHITE)); 
    429438        sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_MOVES), moves); 
     
    451460 
    452461// =========  MODULE INIT ================= 
    453 #include "module_load.h" 
     462 
    454463int module_idx=-1; 
    455464 
     
    470479// RETURN VALUE: 1 error, 0 ok 
    471480//--------------------------------------------------------- 
    472 int _module_loader( void** chdk_export_list ) 
     481int _module_loader( unsigned int* chdk_export_list ) 
    473482{ 
    474   if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     483  if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    475484     return 1; 
     485 
    476486  if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) ) 
    477487          return 1; 
    478488 
    479   // Safe bind of conf. 
    480   tConfigVal configVal; 
    481   CONF_BIND_INT(40, conf_sokoban_level ); 
     489  config_restore(&conf_info[0], "A/CHDK/MODULES/CFG/sokoban.cfg", sizeof(conf_info)/sizeof(conf_info[0]), 0, 0); 
    482490 
    483491  return 0; 
    484492} 
    485  
    486493 
    487494 
     
    492499int _module_unloader() 
    493500{ 
    494   return 0; 
     501    config_save(&conf_info[0], "A/CHDK/MODULES/CFG/sokoban.cfg", sizeof(conf_info)/sizeof(conf_info[0])); 
     502    return 0; 
    495503} 
    496504 
     
    504512  module_idx=moduleidx; 
    505513 
    506   int rv = gui_sokoban_init(); 
     514  int rv = 0; 
     515  if ((mode_get()&MODE_MASK) != MODE_PLAY) { 
     516      gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE, 
     517                    MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, 0); 
     518  } else { 
     519        rv = gui_sokoban_init(); 
     520  } 
    507521  if ( ! rv ) 
    508522        module_async_unload(moduleidx);         // fail to init - "unload me" 
  • trunk/core/gui_tetris.c

    r1527 r1569  
    687687} 
    688688 
     689int basic_module_init() { 
     690  gui_set_mode(&GUI_MODE_TETRIS); 
     691  gui_tetris_init(); 
     692  return 1; 
     693} 
     694 
    689695void gui_tetris_draw(){ 
    690696  gameUpdate(game); 
     
    730736} 
    731737 
    732 // =========  MODULE INIT ================= 
    733 #include "module_load.h" 
    734 int module_idx=-1; 
    735  
    736 /***************** BEGIN OF AUXILARY PART ********************* 
    737   ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
    738  **************************************************************/ 
    739  
    740 void* MODULE_EXPORT_LIST[] = { 
    741         /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
    742         /* 1 */ (void*)0 
    743                 }; 
    744  
    745  
    746 //--------------------------------------------------------- 
    747 // PURPOSE:   Bind module symbols with chdk.  
    748 //              Required function 
    749 // PARAMETERS: pointer to chdk list of export 
    750 // RETURN VALUE: 1 error, 0 ok 
    751 //--------------------------------------------------------- 
    752 int _module_loader( void** chdk_export_list ) 
    753 { 
    754   if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    755      return 1; 
    756  
    757   if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) ) 
    758           return 1; 
    759  
    760   return 0; 
    761 } 
    762  
    763  
    764  
    765 //--------------------------------------------------------- 
    766 // PURPOSE: Finalize module operations (close allocs, etc) 
    767 // RETURN VALUE: 0-ok, 1-fail 
    768 //--------------------------------------------------------- 
    769 int _module_unloader() 
    770 { 
    771         GUI_MODE_TETRIS.magicnum = 0;   //sanity clean to prevent accidentaly assign/restore guimode to unloaded module  
    772   
    773     deleteGame(game); 
    774  
    775     return 0; 
    776 } 
    777  
    778  
    779 //--------------------------------------------------------- 
    780 // PURPOSE: Default action for simple modules (direct run) 
    781 // NOTE: Please comment this function if no default action and this library module 
    782 //--------------------------------------------------------- 
    783 int _module_run(int moduleidx, int argn, int* arguments) 
    784 { 
    785   module_idx=moduleidx; 
    786  
    787   gui_set_mode(&GUI_MODE_TETRIS); 
    788   gui_tetris_init(); 
    789  
    790   return 0; 
    791 } 
    792  
    793  
    794738/******************** Module Information structure ******************/ 
    795739 
  • trunk/core/luascript.c

    r1527 r1569  
    1414#include "console.h" 
    1515#include "action_stack.h" 
    16 #include "motion_detector.h" 
    1716#include "ptp.h" 
    1817#include "core.h" 
     
    779778static int luaCB_md_get_cell_diff( lua_State* L ) 
    780779{ 
    781   lua_pushnumber( L, md_get_cell_diff(luaL_checknumber(L,1), 
    782                                       luaL_checknumber(L,2))); 
    783   return 1; 
     780    if (module_mdetect_load()) 
     781        lua_pushnumber( L, libmotiondetect->md_get_cell_diff(luaL_checknumber(L,1), luaL_checknumber(L,2))); 
     782    else 
     783        lua_pushnumber( L, 0 ); 
     784    return 1; 
    784785} 
    785786 
     
    803804  int pixels_step = (luaL_optnumber(L,15,6)); 
    804805  int msecs_before_trigger = (luaL_optnumber(L,16,0)); 
    805   if(md_init_motion_detector( 
     806  if (module_mdetect_load() && libmotiondetect->md_init_motion_detector( 
    806807    columns, rows, pixel_measure_mode, detection_timeout,  
    807808    measure_interval, threshold, draw_grid, 
     
    825826    kbd_reset_autoclicked_key(); 
    826827 
     828    // Push selected file as script return value 
    827829        lua_pushstring( Lt, (fn && fn[0])? fn : NULL ); 
    828  
    829830} 
    830831 
  • trunk/core/main.c

    r1527 r1569  
    128128} 
    129129 
    130 int core_get_free_memory() { 
     130int core_get_free_memory() 
     131{ 
     132    cam_meminfo camera_meminfo; 
     133 
    131134#if defined(OPT_EXMEM_MALLOC) && !defined(OPT_EXMEM_TESTING) 
    132135        // If using the exmem / suba memory allocation system then don't need 
    133136        // to try allocating memory to find out how much is available 
    134137        // Call function to scan free list for the largest free block available. 
    135     cam_meminfo camera_meminfo; 
    136138    GetExMemInfo(&camera_meminfo); 
     139#else 
     140    // Call function to fill memory info structure and return size of largest free block 
     141    // If implemented this will use firmware function, otherwise it will calculate largest 
     142    // free block 
     143    GetMemInfo(&camera_meminfo); 
     144#endif 
     145 
    137146    return camera_meminfo.free_block_max_size; 
    138 #elif defined(CAM_FIRMWARE_MEMINFO) 
    139     // Call firmware function to fill memory info structure and return size of largest free block 
    140     cam_meminfo camera_meminfo; 
    141     GetMemInfo(&camera_meminfo); 
    142     return camera_meminfo.free_block_max_size; 
    143 #else 
    144         int size, l_size, d; 
    145     char* ptr; 
    146  
    147     size = 16; 
    148     while (1) { 
    149         ptr= malloc(size); 
    150         if (ptr) { 
    151             free(ptr); 
    152             size <<= 1; 
    153         } else 
    154             break; 
    155     } 
    156  
    157     l_size = size; 
    158     size >>= 1; 
    159     d=1024; 
    160     while (d) { 
    161         ptr = malloc(size); 
    162         if (ptr) { 
    163             free(ptr); 
    164             d = l_size-size; 
    165             if (d<0) d=-d; 
    166             l_size = size; 
    167             size += d>>1; 
    168         } else { 
    169             d = size-l_size; 
    170             if (d<0) d=-d; 
    171             l_size = size; 
    172             size -= d>>1; 
    173         } 
    174          
    175     } 
    176     return size-1; 
    177 #endif 
    178147} 
    179148 
     
    226195    mkdir("A/CHDK/BOOKS"); 
    227196    mkdir("A/CHDK/MODULES"); 
     197    mkdir("A/CHDK/MODULES/CFG"); 
    228198    mkdir("A/CHDK/GRIDS"); 
    229199#ifdef OPT_CURVES 
     
    271241 
    272242#ifdef OPT_EDGEOVERLAY 
    273             if(conf.edge_overlay_thresh && conf.edge_overlay_enable) { 
     243            if(((gui_get_mode()==GUI_MODE_NONE) || (gui_get_mode()==GUI_MODE_ALT)) && conf.edge_overlay_thresh && conf.edge_overlay_enable) { 
    274244 
    275245                                // We need to skip first tick because stability 
  • trunk/core/module_exportlist.c

    r1527 r1569  
    1515#include "gui_draw.h" 
    1616#include "gui_batt.h" 
     17#include "gui_space.h" 
    1718#include "gui_menu.h" 
    1819#include "gui_osd.h" 
     
    2122#include "conf.h" 
    2223#include "raw.h" 
    23 #include "bitvector.h" 
    2424#include "font.h" 
    2525 
     
    4040 
    4141 
    42  
    4342// ** SECTION 1: DEFINE UNDECLARED EXPORTED ITEMS 
    44  
    45 #ifndef CAM_FIRMWARE_MEMINFO 
    46 #define GetMemInfo 0 
    47 #endif 
    4843 
    4944 
     
    8277char COLOR__EXPORTEDSYM_HISTO_RG_PLAY = COLOR_HISTO_RG_PLAY ; 
    8378 
    84  
    8579/* EXPORTED_DEFINES_END */ 
    8680 
     81 
    8782// ** SECTION 3: LIST OF EXPORTED SYMBOLS (pointer to function/variable) 
    88 //    1. DO NOT CHANGE ORDER AND DO NOT DELETE EXISTED ENTRIES 
    89 //    2. VARIABLE conf SHOULDN'T EXIST IN THE LIST TO KEEP ISOLATION. USE set|get_chdk_conf|get_chdk_conf_ptr INSTEAD 
    90 //      STOPLIST: conf, open, opendir, closedir, rewinddir, readdir, stat 
    91  
    92 void* CHDK_EXPORT_LIST[] = { 
    93             (void*)EXPORTLIST_MAGIC_NUMBER, 
    94             (void*)EXPORTLIST_LAST_IDX, 
     83//      STOPLIST: open, opendir, closedir, rewinddir, readdir, stat 
     84 
     85// This section is parsed by the makeexport.c program to generate the 
     86// symbol hash table loaded later (from module_hashlist.h) 
     87// Symbols to be exported should be on seperate lines, blank lines and '//' style comments are allowed 
     88 
     89#if 0 
     90{ 
    9591                        module_async_unload, 
    9692                        module_set_flags, 
    97                         conf_getValue, 
    9893                        module_run, 
     94                        module_get_adr, 
     95                        module_async_unload_allrunned, 
     96                        module_rawop_load, 
     97            module_rawop_unload, 
     98            module_mpopup_init, 
     99                        module_convert_dng_to_chdk_raw, 
     100            module_fselect_init, 
     101            module_fselect_init_w_mode, 
     102            module_grids_load, 
     103            module_find_symbol_address, 
     104            module_restore_edge, 
     105            module_save_edge, 
     106 
     107            &altGuiHandler, 
     108            &camera_info, 
     109            &camera_screen, 
     110            &camera_sensor, 
     111            &gui_version, 
     112            &conf, 
    99113 
    100114            malloc, 
     
    102116            umalloc, 
    103117            ufree, 
    104             safe_open, 
     118 
    105119            write, 
    106120            lseek, 
     121            safe_open, 
    107122            close, 
    108123            read, 
    109124            remove, 
    110125            rename, 
     126            safe_stat, 
     127            safe_opendir, 
     128            safe_readdir, 
     129            safe_closedir, 
     130                        mkdir, 
     131 
    111132            fopen, 
    112133            fclose, 
     
    114135            fread, 
    115136            fwrite, 
    116             safe_stat, 
    117             safe_opendir, 
    118             safe_readdir, 
    119             safe_closedir, 
    120137 
    121138            get_tick_count, 
     
    125142            rand, 
    126143                        srand, 
     144            qsort, 
     145                        msleep, 
    127146 
    128147            lang_str, 
     
    134153            strchr, 
    135154                        strcmp, 
     155            strtol, 
     156            strrchr, 
     157            strncpy, 
    136158            memcpy, 
     159            memset, 
    137160 
    138161            draw_txt_string, 
     
    144167                        draw_line, 
    145168                        draw_char, 
     169            draw_get_pixel, 
     170            draw_pixel, 
     171            draw_restore, 
     172            draw_txt_char, 
     173                        draw_rect_thick, 
     174                        draw_filled_rect_thick, 
     175            draw_rect_shadow, 
     176            draw_ellipse, 
     177            draw_clear, 
     178            draw_set_draw_proc, 
    146179 
    147180            gui_get_mode, 
    148181            gui_set_mode, 
    149182                        gui_default_kbd_process_menu_btn, 
    150  
    151             vid_get_viewport_fb, 
    152             vid_get_viewport_height, 
    153             vid_get_bitmap_fb, 
    154             hook_raw_image_addr, 
    155             hook_raw_size, 
    156             kbd_get_autoclicked_key, 
    157  
    158183                        get_batt_perc, 
    159184                        gui_osd_draw_clock, 
    160185                        gui_mbox_init, 
    161  
    162                         // for rawop.flt 
    163             GetFreeCardSpaceKb, 
    164             debug_led, 
    165186            gui_browser_progress_show, 
    166          
    167                 // for edgeovr.flt 
     187            gui_activate_sub_menu, 
     188            gui_enum_value_change, 
     189                        gui_force_restore, 
     190                        gui_menu_run_fltmodule, 
     191 
     192            gui_osd_calc_dof, 
     193            gui_osd_draw_dof, 
     194            gui_batt_draw_osd, 
     195            gui_space_draw_osd, 
     196            gui_osd_draw_state, 
     197            gui_osd_draw_raw_info, 
     198            gui_osd_draw_values, 
     199            gui_osd_draw_temp, 
     200            gui_osd_draw_histo, 
     201 
     202            vid_get_bitmap_fb, 
     203            vid_get_viewport_fb, 
     204            vid_get_viewport_fb_d, 
     205            vid_get_viewport_live_fb, 
     206            vid_get_viewport_height, 
    168207                        vid_get_viewport_width, 
    169208            vid_get_viewport_byte_width, 
    170209            vid_get_viewport_xoffset, 
    171210            vid_get_viewport_yoffset, 
     211            vid_get_viewport_image_offset, 
     212            vid_get_viewport_row_offset, 
    172213            vid_get_viewport_yscale, 
    173             vid_get_viewport_fb_d, 
     214 
     215                        get_raw_image_addr, 
     216            hook_raw_image_addr, 
     217            hook_raw_size, 
     218                        raw_prepare_develop, 
     219 
     220            kbd_get_autoclicked_key, 
    174221            kbd_is_key_pressed, 
    175             bv_create, 
    176             bv_get, 
    177             bv_set, 
    178             bv_free, 
    179             draw_get_pixel, 
    180             draw_pixel, 
    181             draw_restore, 
    182             memset, 
     222            kbd_key_press, 
     223                        kbd_get_clicked_key, 
     224                        kbd_reset_autoclicked_key, 
     225            get_jogdial_direction, 
     226 
     227                        // for rawop.flt 
     228            GetFreeCardSpaceKb, 
     229            debug_led, 
     230 
    183231                        mode_get, 
    184232            shooting_get_zoom, 
     
    186234 
    187235                        // for txtread.flt 
    188             draw_txt_char, 
     236            current_font, 
    189237            rbf_char_width, 
    190238            rbf_font_height, 
    191239            rbf_draw_char, 
    192240            rbf_load, 
    193             current_font, 
    194241            rbf_load_from_8x16, 
    195242            rbf_set_codepage, 
    196             get_jogdial_direction, 
    197  
    198                         // for palette.flt 
    199                         draw_rect_thick, 
    200                         draw_filled_rect_thick, 
     243                        rbf_draw_string_len, 
     244                        rbf_draw_menu_header, 
    201245 
    202246                        // for modinsp.flt 
    203                         module_get_adr, 
    204                         module_async_unload_allrunned, 
    205247                        GetMemInfo, 
     248                        GetExMemInfo, 
    206249 
    207250                        // for fselect.flt 
    208                         module_rawop_load, 
    209             module_rawop_unload, 
    210             module_mpopup_init, 
    211             qsort, 
    212251            img_prefixes, 
    213252            img_exts, 
    214             strrchr, 
    215             strncpy, 
    216                         msleep, 
    217253            GetTotalCardSpaceKb, 
    218                         module_convert_dng_to_chdk_raw, 
    219                         raw_prepare_develop, 
    220  
    221                         // curves.flt                    
    222                         get_raw_image_addr, 
    223                         shooting_get_ev_correction1, 
    224  
    225                         // mpopup.flt                    
    226             draw_rect_shadow, 
    227                         kbd_get_clicked_key, 
    228                         kbd_reset_autoclicked_key, 
    229254 
    230255                        // tetris.flt 
    231256                        TurnOnBackLight, 
    232257                        TurnOffBackLight, 
    233                         mkdir, 
    234  
    235                         // modlist.flt 
     258 
     259                        // modmenu.flt 
    236260                        load_from_file, 
    237                         rbf_draw_string_len, 
    238                         rbf_draw_menu_header, 
    239                         gui_force_restore, 
    240  
    241                         // modmenu.flt 
    242                         gui_menu_run_fltmodule, 
     261 
     262                        action_stack_create, 
     263                        action_pop, 
     264                        action_push, 
     265                        action_push_delay, 
     266            action_push_release, 
     267                        action_stack_standard, 
     268                        console_clear, 
     269                        console_add_line, 
     270 
     271            shooting_set_tv96_direct, 
     272                        shooting_get_iso_market, 
     273                        shooting_get_ev_correction1, 
     274 
     275            get_focal_length, 
     276                        get_effective_focal_length, 
     277                        get_parameter_data, 
     278                        get_property_case, 
     279 
     280            &shutter_open_time, 
     281                        &state_shooting_progress, 
     282                        get_raw_pixel, 
     283                        patch_bad_pixel, 
     284                         
     285                        pow_calc, 
     286                        pow_calc_2, 
    243287 
    244288                        // export palette 
     
    272316                        &COLOR__EXPORTEDSYM_HISTO_RG_PLAY, 
    273317 
    274                         // profile.flt 
    275                         find_mnu, 
    276                         lang_strhash31, 
    277  
    278                         action_stack_create, 
    279                         action_pop, 
    280                         action_push, 
    281                         action_push_delay, 
    282                         action_stack_standard, 
    283                         console_clear, 
    284                         console_add_line, 
    285                         shooting_set_tv96_direct, 
    286                         shooting_get_iso_market, 
    287                         get_focal_length, 
    288                         get_effective_focal_length, 
    289                         get_parameter_data, 
    290                         get_property_case, 
    291                         &shutter_open_time, 
    292                         get_raw_pixel, 
    293                         &state_shooting_progress, 
    294                         patch_bad_pixel, 
    295                          
    296                         pow_calc, 
    297                         pow_calc_2, 
    298  
    299             &camera_info, 
    300             &camera_screen, 
    301             &camera_sensor, 
    302             &altGuiHandler, 
    303             &gui_version, 
    304                         0 
     318                        module_tbox_get_version, 
     319                        module_tbox_run, 
     320 
     321            config_save, 
     322            config_restore, 
     323} 
     324#endif 
     325 
     326// Symbol hash table for resolving exported symbol references 
     327sym_hash symbol_hash_table[] = 
     328{ 
     329    { EXPORTLIST_MAGIC_NUMBER, (void*)EXPORTLIST_LAST_IDX }, 
     330#include "module_hashlist.h" 
    305331}; 
  • trunk/core/module_load.c

    r1527 r1569  
    2121//********************************************************/ 
    2222 
    23 extern void* CHDK_EXPORT_LIST[]; 
    24  
    2523#define MAX_NUM_LOADED_MODULES 10 
    2624#define BUFFER_FOR_READ_SIZE   4096 
     
    8179// =1- if correspondend module ask to unload it on exit from main menu 
    8280static unsigned char module_flags[MAX_NUM_LOADED_MODULES];  
    83  
    8481 
    8582//----------------------------------------------- 
     
    157154} 
    158155 
     156// Find symbol address in array from hash id 
     157void* module_find_symbol_address(uint32_t importid) 
     158{ 
     159    // binary search (first entry is magic number & entry count) 
     160    int min = 1, max = EXPORTLIST_LAST_IDX; 
     161    do 
     162    { 
     163        int mid = (min + max) >> 1; 
     164        if (importid == symbol_hash_table[mid].hash) 
     165            return symbol_hash_table[mid].address; 
     166        else if (importid > symbol_hash_table[mid].hash) 
     167            min = mid + 1; 
     168        else 
     169            max = mid - 1; 
     170    } while (min <= max); 
     171    return 0; 
     172} 
     173 
    159174static int module_do_imports( struct flat_hdr* flat, void* relocbuf, uint32_t import_count ) 
    160175{ 
    161176        int i; 
    162         uint32_t importidx; 
     177        void* importaddress; 
    163178        uint32_t* ptr; 
    164179        unsigned char* buf = (unsigned char*)flat; 
     
    168183        { 
    169184                ptr = (uint32_t*)( buf + ((import_record_t*)relocbuf)->offs ); 
    170                 importidx = ((import_record_t*)relocbuf)->importidx; 
    171  
    172           //@tsv todo: if (*relocbuf>=flat->reloc_start) error_out_of_bound 
    173                 // No such symbol to import 
    174                 if ( importidx<2 || importidx>EXPORTLIST_LAST_IDX ) 
    175                         return 0; 
    176  
    177                 // Empty symbol - module could only if import such symbol manually 
    178                 if ( CHDK_EXPORT_LIST[importidx]==0 ) 
    179                         return 0; 
    180  
    181                 *ptr += (uint32_t)CHDK_EXPORT_LIST[importidx]; 
     185                importaddress = module_find_symbol_address(((import_record_t*)relocbuf)->importidx); 
     186 
     187        if (importaddress == 0) return 0; 
     188 
     189                *ptr += (int)importaddress;  //(uint32_t)CHDK_EXPORT_LIST[importidx]; 
    182190        relocbuf = ((import_record_t*)relocbuf)+1; 
    183191        }   
     
    256264// RETURN:    -1 - failed, >=0 =idx of module 
    257265//----------------------------------------------- 
    258 int module_load( char* name, _module_loader_t callback) 
     266int module_load( char* name, _module_bind_t callback) 
    259267{ 
    260268   int idx; 
     
    277285          // reset possible unload request 
    278286          module_unload_request[idx]=0; 
     287      if ( callback ) 
     288          callback( (void**) modules[idx]->_module_exportlist ); 
    279289      return idx; 
    280290   } 
     
    381391 
    382392   if ( modules[idx]->_module_loader ) { 
    383                 uint32_t x = ((_module_loader_t) modules[idx]->_module_loader )(CHDK_EXPORT_LIST); 
    384         bind_err = bind_err || x; //( (_module_loader_t) modules[idx]->_module_loader )(CHDK_EXPORT_LIST)); 
     393                uint32_t x = ((_module_loader_t) modules[idx]->_module_loader )((unsigned int*)&symbol_hash_table[0]); 
     394        bind_err = bind_err || x; 
    385395   } 
    386396 
     
    402412// RETURN VALUE: passed from module. -1 if something was failed 
    403413//----------------------------------------------- 
    404 int module_run(char* name, _module_loader_t callback, int argn, void* args, enum ModuleUnloadMode unload_after) 
     414int module_run(char* name, _module_bind_t callback, int argn, void* args, enum ModuleUnloadMode unload_after) 
    405415{ 
    406416   int rv = -1; 
     
    432442 
    433443//----------------------------------------------- 
    434 void module_unload(char* name) 
    435 { 
    436    int idx; 
     444void module_unload_idx(int idx) 
     445{ 
    437446   _module_loader_t callback; 
    438  
    439    idx = module_find(name); 
    440447 
    441448   if ( idx>=0 ) { 
     
    457464} 
    458465 
     466void module_unload(char* name) 
     467{ 
     468    module_unload_idx(module_find(name)); 
     469} 
    459470 
    460471//----------------------------------------------- 
  • trunk/core/module_load.h

    r1527 r1569  
    1515 
    1616 
     17// Struct for symbol hash table entries 
     18typedef struct 
     19{ 
     20    uint32_t    hash; 
     21    void        *address; 
     22} sym_hash; 
     23 
     24// Hashed Symbol table for exported symbols 
     25extern sym_hash symbol_hash_table[]; 
     26 
     27 
    1728// Base typedefs 
    1829//------------------- 
     
    2031#define EXPORTLIST_MAGIC_NUMBER  0x43215678 
    2132 
    22 typedef int (*_module_loader_t)( void** chdk_export_list ); 
     33typedef int (*_module_bind_t)( void** chdk_export_list ); 
     34typedef int (*_module_loader_t)( unsigned int* chdk_export_list ); 
    2335typedef int (*_module_unloader_t)(); 
    2436typedef int (*_module_run_t)(int moduleidx, int argn, int* arguments); 
     
    3749int module_check_is_exist(char* name); 
    3850int module_find(char * name ); 
    39 int module_load( char* name, _module_loader_t callback); 
    40 int module_run(char* name, _module_loader_t callback, int argn, void* args, enum ModuleUnloadMode unload_after); 
     51int module_load( char* name, _module_bind_t callback); 
     52int module_run(char* name, _module_bind_t callback, int argn, void* args, enum ModuleUnloadMode unload_after); 
    4153void module_unload(char* name); 
     54void module_unload_idx(int module_idx); 
     55void* module_find_symbol_address(uint32_t importid); 
    4256 
    4357// Flag for modules which couldn't be safely autounloaded (lua, basic,..) 
     
    5468void module_tick_unloader(); 
    5569 
    56 // In-module binding to conf. 
    57 //--------------------------- 
    58 #define CONF_BIND_INT(idConf,var)  if ( conf_getValue(idConf, &configVal) == CONF_VALUE ) {     var = configVal.pInt; } else { return 1;} 
    59 #define CONF_BIND_COLOR(idConf,var)  if ( conf_getValue(idConf, &configVal) == CONF_VALUE ) {   var = (color*)configVal.pInt; } else { return 1;} 
    60 #define CONF_BIND_STR(idConf,var)  if ( conf_getValue(idConf, &configVal) == CONF_CHAR_PTR ) {  var = (char*)configVal.str; } else { return 1;} 
    61  
    6270// API versions check 
    6371//--------------------------- 
  • trunk/core/modules.c

    r1527 r1569  
    1414#include "gui_draw.h" 
    1515#include "dng.h" 
     16#include "lang.h" 
     17 
     18/************* GENERIC ******/ 
     19 
     20static int bind_module_generic( void** export_list, void** lib, int count, int major, int minor ) 
     21{ 
     22    *lib = 0; 
     23 
     24        // Unbind 
     25        if ( !export_list ) { 
     26        return 0; 
     27        } 
     28 
     29        // Bind 
     30        if ( (unsigned int)export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     31             return 1; 
     32        if ( (unsigned int)export_list[1] < count ) 
     33         return 1; 
     34 
     35        *lib = (void*)export_list[2]; 
     36 
     37        if ( !*lib ) 
     38         return 1; 
     39        if ( (major > 0) && !API_VERSION_MATCH_REQUIREMENT( *((int*)(*lib)), major, minor ) ) { 
     40                *lib=0; 
     41                return 1; 
     42        } 
     43 
     44        return 0; 
     45} 
     46 
     47// Return: 0-fail, addr-ok 
     48static void* module_load_generic(void **lib, char *name, int (*callback)(void**), int flags) 
     49{ 
     50    if (*lib == 0) 
     51    { 
     52        int module_idx = module_load(name, callback); 
     53        if ( module_idx < 0 ) 
     54            module_unload(name);   
     55        else 
     56        { 
     57            if (flags) 
     58                    module_set_flags(module_idx, flags); 
     59        } 
     60    } 
     61 
     62    return *lib; 
     63} 
    1664 
    1765/************* DYNAMIC LIBRARY RAWOPERATION ******/ 
     
    2876struct librawop_sym* librawop; 
    2977 
     78void module_rawop_unload() 
     79{ 
     80        if (librawop) 
     81    { 
     82        module_unload(MODULE_NAME_RAWOP);   
     83        librawop = 0; 
     84    } 
     85} 
     86 
    3087static int bind_module_rawop( void** export_list ) 
    3188{ 
    32           // Unbind 
    33         if ( !export_list ) { 
    34                 librawop=0; 
    35         return 0; 
    36         } 
    37  
    38         // Bind 
    39         if ( (unsigned int)export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    40              return 1; 
    41         if ( (unsigned int)export_list[1] <3 ) 
    42          return 1; 
    43  
    44         librawop = export_list[2]; 
    45  
    46         if ( !librawop ) 
    47          return 1; 
    48  
    49     /* NO API VERSION CHECK HERE - EACH MODULE CHECK THIS AGAINST ITS REQUIREMENT 
    50         if ( !API_VERSION_MATCH_REQUIREMENT( librawop->version, 1, 0 ) ) { 
    51                 librawop=0; 
    52                 return 1; 
    53         } 
    54     */ 
    55  
    56         return 0; 
    57 } 
    58  
    59 void module_rawop_unload() 
    60 { 
    61         if (librawop==0) 
    62         return; 
    63  
    64         module_unload(MODULE_NAME_RAWOP);   
    65 } 
    66  
     89    return bind_module_generic(export_list, (void**)&librawop, 1, 0, 0); 
     90} 
    6791 
    6892// Return: 0-fail, otherwise - bind list 
    6993struct librawop_sym* module_rawop_load() 
    7094{ 
    71   static int module_idx=-1; 
    72  
    73   if (librawop) 
    74      return librawop; 
    75  
    76   module_idx=module_load(MODULE_NAME_RAWOP, bind_module_rawop ); 
    77   if ( module_idx<0 ) 
    78          module_unload(MODULE_NAME_RAWOP);   
    79  
    80   return librawop; 
    81 } 
    82  
     95    return module_load_generic((void**)&librawop, MODULE_NAME_RAWOP, bind_module_rawop, 0); 
     96} 
    8397 
    8498 
    8599/************* DYNAMIC LIBRARY EDGE OVERLAY ******/ 
    86100 
     101#ifdef OPT_EDGEOVERLAY 
     102 
    87103#define MODULE_NAME_EDGEOVR "edgeovr.flt" 
    88104 
     105// Storage and interface for edge overlay 'image' buffer. 
     106// This is so the previous overlay can survive if the module gets unloaded 
     107static void* saved_edgebuf = 0; 
     108static int saved_edgestate = 0; 
     109void module_restore_edge(void **buf, int *state) { *buf = saved_edgebuf; *state = saved_edgestate; } 
     110void module_save_edge(void* buf, int state)      { saved_edgebuf = buf; saved_edgestate = state; } 
     111 
    89112struct libedgeovr_sym* libedgeovr; 
    90113 
    91114static int bind_module_edgeovr( void** export_list ) 
    92115{ 
    93           // Unbind 
    94         if ( !export_list ) { 
    95                 libedgeovr =0; 
    96         return 0; 
    97         } 
    98  
    99         // Bind 
    100         if ( (unsigned int)export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    101              return 1; 
    102         if ( (unsigned int)export_list[1] <3 ) 
    103          return 1; 
    104  
    105         libedgeovr = export_list[2]; 
    106         if ( !libedgeovr ) 
    107          return 1; 
    108         if ( !API_VERSION_MATCH_REQUIREMENT( libedgeovr->version, 1, 0 ) ) { 
    109                 libedgeovr=0; 
    110                 return 1; 
    111         } 
    112  
    113         return 0; 
     116    return bind_module_generic(export_list, (void**)&libedgeovr, 1, 1, 0); 
    114117} 
    115118 
     
    117120struct libedgeovr_sym* module_edgeovr_load() 
    118121{ 
    119   if (libedgeovr) 
    120      return libedgeovr; 
    121  
    122   // This flag is because edgeovr called each tick 
    123   //   If module loading failed, then do not try to load it until reboot 
    124   //    (otherwise we will try to load module each tick) 
    125   static int flag_load_fail = 0; 
    126   static int module_idx=-1; 
    127  
    128   if ( flag_load_fail==0 ) 
    129   { 
    130     module_idx=module_load(MODULE_NAME_EDGEOVR, bind_module_edgeovr ); 
    131         if ( module_idx<0 ) { 
    132                 flag_load_fail = 1; 
    133                 module_unload(MODULE_NAME_EDGEOVR);   
    134         } 
    135         else { 
    136                 // This library never unloaded once it is loaded 
    137                 // Reason - it should keep its data during whole session 
    138                 module_set_flags(module_idx, MODULE_FLAG_DISABLE_AUTOUNLOAD); 
    139         } 
    140   } 
    141  
    142   return libedgeovr; 
     122    // This flag is because edgeovr called each tick 
     123    //   If module loading failed, then do not try to load it until reboot 
     124    //    (otherwise we will try to load module each tick) 
     125    static int flag_load_fail = 0; 
     126 
     127    if ( flag_load_fail==0 ) 
     128    { 
     129        module_load_generic((void**)&libedgeovr, MODULE_NAME_EDGEOVR, bind_module_edgeovr, MODULE_FLAG_DISABLE_AUTOUNLOAD); 
     130 
     131        if (libedgeovr == 0) 
     132                flag_load_fail = 1; 
     133    } 
     134 
     135    return libedgeovr; 
    143136} 
    144137 
     
    147140// void module_edgeovr_unload() {} 
    148141 
     142#endif 
     143 
     144 
     145/************* DYNAMIC LIBRARY MOTION DETECT ******/ 
     146 
     147#define MODULE_NAME_MDETECT "mdetect.flt" 
     148 
     149struct libmotiondetect_sym* libmotiondetect; 
     150 
     151static int bind_module_motiondetect( void** export_list ) 
     152{ 
     153    return bind_module_generic(export_list, (void**)&libmotiondetect, 1, 1, 0); 
     154} 
     155 
     156// Return: 0-fail, 1-ok 
     157struct libmotiondetect_sym* module_mdetect_load() 
     158{ 
     159    return module_load_generic((void**)&libmotiondetect, MODULE_NAME_MDETECT, bind_module_motiondetect, MODULE_FLAG_DISABLE_AUTOUNLOAD); 
     160} 
     161 
     162 
     163/************* DYNAMIC LIBRARY ZEBRA ******/ 
     164 
     165#define MODULE_NAME_ZEBRA "zebra.flt" 
     166 
     167struct libzebra_sym* libzebra; 
     168 
     169static int bind_module_zebra( void** export_list ) 
     170{ 
     171    return bind_module_generic(export_list, (void**)&libzebra, 1, 1, 0); 
     172} 
     173 
     174// Return: 0-fail, 1-ok 
     175struct libzebra_sym* module_zebra_load() 
     176{ 
     177    return module_load_generic((void**)&libzebra, MODULE_NAME_ZEBRA, bind_module_zebra, MODULE_FLAG_DISABLE_AUTOUNLOAD); 
     178} 
     179 
    149180 
    150181/************* DYNAMIC LIBRARY CURVES ******/ 
    151182 
     183#if defined(OPT_CURVES) 
     184 
    152185#define MODULE_NAME_CURVES "curves.flt" 
    153186 
     
    156189static int bind_module_curves( void** export_list ) 
    157190{ 
    158           // Unbind 
    159         if ( !export_list ) { 
    160                 libcurves=0; 
    161         return 0; 
    162         } 
    163  
    164         // Bind 
    165         if ( (unsigned int)export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    166              return 1; 
    167         if ( (unsigned int)export_list[1] <3 ) 
    168          return 1; 
    169  
    170         libcurves = export_list[2]; 
    171  
    172         if ( !libcurves ) 
    173          return 1; 
    174         if ( !API_VERSION_MATCH_REQUIREMENT( libcurves->version, 1, 0 ) ) { 
    175                 librawop=0; 
    176                 return 1; 
    177         } 
    178  
    179         return 0; 
     191    return bind_module_generic(export_list, (void**)&libcurves, 1, 1, 0); 
    180192} 
    181193 
     
    183195struct libcurves_sym* module_curves_load() 
    184196{ 
    185   if (libcurves) 
    186      return libcurves; 
    187  
    188   static int module_idx=-1; 
    189  
    190   module_idx=module_load(MODULE_NAME_CURVES, bind_module_curves ); 
    191   if ( module_idx<0 ) 
    192                 module_unload(MODULE_NAME_CURVES);   
    193   else { 
    194         // This library never unloaded once it is loaded 
    195         // Reason - changing mode mode from LUA stored inside module only 
    196         module_set_flags(module_idx, MODULE_FLAG_DISABLE_AUTOUNLOAD); 
    197  
    198         // Initialize - in module 
    199         // curve_init_mode(); 
    200   } 
    201  
    202   return libcurves; 
     197    return module_load_generic((void**)&libcurves, MODULE_NAME_CURVES, bind_module_curves, 0); 
     198} 
     199 
     200#endif 
     201 
     202 
     203/************* DYNAMIC LIBRARY GRIDS ******/ 
     204 
     205#define MODULE_NAME_GRIDS "grids.flt" 
     206 
     207struct libgrids_sym* libgrids; 
     208 
     209static int bind_module_grids( void** export_list ) 
     210{ 
     211    return bind_module_generic(export_list, (void**)&libgrids, 1, 1, 0); 
     212} 
     213 
     214// Return: 0-fail, addr-ok 
     215struct libgrids_sym* module_grids_load() 
     216{ 
     217    return module_load_generic((void**)&libgrids, MODULE_NAME_GRIDS, bind_module_grids, 0); 
    203218} 
    204219 
     
    246261} 
    247262 
    248  
    249  
    250263/************* MODULE DNG ******/ 
    251264 
     
    256269 
    257270struct libdng_sym* libdng; 
    258  
    259 #if DNG_SUPPORT 
    260 static int bind_module_dng( void** export_list ) 
    261 { 
    262           // Unbind 
    263         if ( !export_list ) { 
    264                 libdng=0; 
    265         return 0; 
    266         } 
    267  
    268         // Bind 
    269         if ( (unsigned int)export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    270              return 1; 
    271         if ( (unsigned int)export_list[1] < 3 ) 
    272          return 1; 
    273  
    274         libdng = export_list[2]; 
    275         if ( libdng==0 ) 
    276          return 1; 
    277  
    278         if ( !API_VERSION_MATCH_REQUIREMENT( libdng->version, 1, 0 ) ) { 
    279                 libdng=0;                
    280                 return 1; 
    281         } 
    282  
    283         return 0; 
    284 } 
    285 #endif 
    286271 
    287272void module_dng_unload(int owner) 
     
    291276        return; 
    292277 
    293         module_dng_semaphore&=~owner; 
     278        module_dng_semaphore &= ~owner; 
    294279        if (module_dng_semaphore) 
    295280                return; 
     
    299284} 
    300285 
     286static int bind_module_dng( void** export_list ) 
     287{ 
     288    return bind_module_generic(export_list, (void**)&libdng, 1, 1, 0); 
     289} 
    301290 
    302291// Return: 0-fail, otherwise - bind list 
     
    304293{ 
    305294#if DNG_SUPPORT 
    306   static int module_idx=-1; 
    307  
    308   module_dng_semaphore|=owner; 
    309   if (libdng) 
    310      return libdng; 
    311  
    312   module_idx=module_load(MODULE_NAME_DNG, bind_module_dng ); 
    313   if ( module_idx<0 ) { 
    314          module_unload(MODULE_NAME_DNG);   
    315          module_dng_semaphore=0; 
    316   } 
    317   else { 
    318          // This module could be unloaded only manualy (because store badpixel) 
    319          module_set_flags(module_idx, MODULE_FLAG_DISABLE_AUTOUNLOAD); 
    320   } 
    321  
    322   return libdng; 
     295    module_dng_semaphore |= owner; 
     296 
     297    module_load_generic((void**)&libdng, MODULE_NAME_DNG, bind_module_dng, MODULE_FLAG_DISABLE_AUTOUNLOAD); 
     298 
     299    if (libdng == 0) 
     300        module_dng_semaphore=0; 
     301 
     302    return libdng; 
    323303#else 
    324   return 0; 
     304    return 0; 
    325305#endif 
    326306} 
     
    344324#endif 
    345325} 
     326 
     327 
     328/************* MODULE TBOX ******/ 
     329 
     330static char* tbox_file_buffer = 0; 
     331static char* tbox_file_buffer_default = "_tbox.flt"; 
     332static int   tbox_file_buffer_size = 0; 
     333static char* charmap_buffer = 0; 
     334static int   charmap_buffer_size = 0; 
     335 
     336// Auxilary function - Parse loaded keymap, ask module for its API version 
     337// Input values: tbox_file_buffer, tbox_file_buffer_size 
     338// Return value: 0-error, otherwise API version 
     339//----------------------------------------------------- 
     340static int module_tbox_charmap_preprocess()  
     341{ 
     342        charmap_buffer = 0; 
     343        charmap_buffer_size = 0; 
     344 
     345        //-- input checks 
     346        if ( tbox_file_buffer==0 || tbox_file_buffer_size<=0 ) 
     347                return 0; 
     348 
     349        int i, ver; 
     350 
     351        //-- Parse: split to lines 
     352        for( i=0; i<tbox_file_buffer_size; i++ ) 
     353           if ( tbox_file_buffer[i] == 0x0d || tbox_file_buffer[i] == 0x0a) 
     354                  tbox_file_buffer[i]=0; 
     355 
     356        //-- First line is name of tbox module 
     357        i = strlen(tbox_file_buffer);           // size 
     358        if ( i==0 ) 
     359                return 0; 
     360 
     361        // tbox "run scenario #1" - argc=1, argv=0 - mean "say your API version" 
     362        ver = module_run(tbox_file_buffer, 0,  1,0, UNLOAD_ALWAYS ); 
     363 
     364        // if mistake on load 
     365        if ( ver<=0 )  
     366                return 0; 
     367 
     368        charmap_buffer=tbox_file_buffer+i+1; 
     369        charmap_buffer_size= tbox_file_buffer_size - (i+1); 
     370 
     371        return ver; 
     372} 
     373 
     374// Check version and existance and tbox api version 
     375// return: 0 if no module exists at all, otherwise version of API of current tbox module 
     376//----------------------------------------------------- 
     377int module_tbox_get_version() 
     378{ 
     379  static int last_loaded_tbox_hash = 0; 
     380  static int cur_tbox_api_version = 0; 
     381 
     382  // -- If keymap is loaded and not changed - return stored value 
     383 
     384  if ( lang_strhash31((int)conf.charmap_file) == last_loaded_tbox_hash ) 
     385    return cur_tbox_api_version; 
     386 
     387  // -- Free resources 
     388 
     389  last_loaded_tbox_hash = 0; 
     390  if ( tbox_file_buffer && tbox_file_buffer!=tbox_file_buffer_default ) 
     391    ufree( tbox_file_buffer ); 
     392 
     393  // -- Try to load keymap file 
     394 
     395  tbox_file_buffer = load_file( conf.charmap_file, &tbox_file_buffer_size ); 
     396 
     397  // Check is module available, otherwise try default one 
     398 
     399  cur_tbox_api_version = module_tbox_charmap_preprocess(); 
     400 
     401 
     402  // if keymap wrong/module can't be loaded - try default 
     403  if ( cur_tbox_api_version==0 ) { 
     404         if ( tbox_file_buffer ) 
     405        ufree(tbox_file_buffer); 
     406 
     407         tbox_file_buffer = tbox_file_buffer_default; 
     408         tbox_file_buffer_size = strlen(tbox_file_buffer); 
     409         cur_tbox_api_version = module_tbox_charmap_preprocess(); 
     410  } 
     411 
     412  if ( cur_tbox_api_version ) 
     413        last_loaded_tbox_hash = lang_strhash31((int)conf.charmap_file); 
     414 
     415  return cur_tbox_api_version; 
     416} 
     417 
     418 
     419//----------------------------------------------------- 
     420void module_tbox_run( int title, int msg, char* defaultvalue, unsigned int maxsize, void (*on_select)(char* newstr)) 
     421{ 
     422        int ver = module_tbox_get_version(); 
     423 
     424        if ( API_VERSION_MATCH_REQUIREMENT( ver, 1, 0 ) ) { 
     425 
     426                // Main "run scenario" - 7 argument, raise textbox 
     427                unsigned int argv[] = { (int)charmap_buffer, 
     428                                                                charmap_buffer_size, 
     429                                                                title, 
     430                                                                msg, 
     431                                                                (unsigned int)defaultvalue, 
     432                                                                maxsize, 
     433                                                                (unsigned int)on_select, 
     434                                                         }; 
     435            module_run(tbox_file_buffer, 0,  sizeof(argv)/sizeof(argv[0]), argv, UNLOAD_IF_ERR); 
     436                 
     437        } 
     438} 
  • trunk/core/modules.h

    r1527 r1569  
    66#include "raw_merge.h" 
    77 
    8 struct librawop_sym* module_rawop_load();               // 0fail, addr-ok 
    9 void module_rawop_unload(); 
    10  
    11  
    128// MODULE "EDGE OVERLAY" 
    139//-------------------------- 
    1410#include "edgeoverlay.h" 
    1511 
    16 struct libedgeovr_sym* module_edgeovr_load();   // 0fail, addr-ok 
     12// MODULE "ZEBRA OVERLAY" 
     13//-------------------------- 
     14#include "zebra.h" 
    1715 
    1816// MODULE "CURVES" 
     
    2018#include "curves.h" 
    2119 
    22 struct libcurves_sym* module_curves_load();             // 0fail, addr-ok 
     20// MODULE "MOTION DETECT" 
     21//-------------------------- 
     22#include "motion_detector.h" 
     23 
     24// MODULE "GRIDS" 
     25//-------------------------- 
     26#include "gui_grid.h" 
    2327 
    2428// MODULE "PALETTE" 
    2529//-------------------------- 
    2630#include "gui_palette.h" 
    27 void module_palette_run(int mode, color st_color, void (*on_select)(color clr)); 
    2831 
    2932// MODULE "FILE SELECTOR" 
    3033//-------------------------- 
    31 void module_fselect_init(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn)); 
    32 void module_fselect_init_w_mode(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn), unsigned int key_redraw_mode); 
     34#include "gui_fselect.h" 
    3335 
    3436// MODULE "MPOPUP" 
    3537//-------------------------- 
    3638#include "gui_mpopup.h" 
    37 void module_mpopup_init(struct mpopup_item* popup_actions, const unsigned int flags, void (*on_select)(unsigned int actn), int mode); 
    38  
    3939 
    4040// MODULE "DNG" 
     
    4242#include "dng.h" 
    4343 
    44 // values of semaphore 
    45 #define LIBDNG_OWNED_BY_RAW                     0x1 
    46 #define LIBDNG_OWNED_BY_CONVERT                 0x2 
    47 #define LIBDNG_OWNED_BY_CREATEBADPIXEL  0x4 
    48  
    49 struct libdng_sym* module_dng_load(int owner);          // 0fail, addr-ok 
    50 void module_dng_unload(int owner); 
    51  
    52 int module_convert_dng_to_chdk_raw(char* fn);           // Return: 0-fail, 1-ok 
    53  
    54  
     44// MODULE "TBOX" 
     45//-------------------------- 
     46int module_tbox_get_version(); 
     47void module_tbox_run( int title, int msg, char* defaultvalue, unsigned int maxsize, void (*on_select)(char* newstr)); 
    5548 
    5649#endif 
  • trunk/core/modules/Makefile

    r1558 r1569  
    1818 
    1919OBJS=../gui_calendar.o ../gui_bench.o ../gui_4wins.o ../gui_mastermind.o ../gui_reversi.o \ 
    20          ../gui_sokoban.o ../gui_read.o ../gui_debug.o  ../gui_tetris.o ../gui_snake.o ../dng.o ../gps.o 
     20         ../gui_sokoban.o ../gui_read.o ../gui_debug.o  ../gui_tetris.o ../gui_snake.o ../gui_games.o ../dng.o ../gps.o 
    2121 
    2222 
    2323CFLAGS+=-DOPT_GENERIC_MODULES 
    24 OPT_OBJS= ../gui_fselect.o ../nothumb.o ../gui_mpopup.o ../curves.o ../edgeoverlay.o ../gui_palette.o 
    25 OPT_FLT= fselect.flt edgeovr.flt curves.flt mpopup.flt palette.flt 
     24OPT_OBJS= ../gui_fselect.o ../nothumb.o ../gui_mpopup.o ../curves.o ../edgeoverlay.o ../bitvector.o ../gui_palette.o ../gui_grid.o ../motion_detector.o ../zebra.o 
     25OPT_FLT= fselect.flt edgeovr.flt curves.flt mpopup.flt palette.flt grids.flt mdetect.flt zebra.flt 
    2626 
    2727 
    2828all: exportlist ../flt.h \ 
    2929                _dng.flt benchm.flt calend.flt 4wins.flt mastmind.flt reversi.flt sokoban.flt _rawop10.flt _rawop12.flt \ 
    30                 txtread.flt memview.flt modinsp.flt tetris.flt snake.flt modmenu.flt $(OPT_FLT) 
     30                txtread.flt memview.flt modinsp.flt tetris.flt snake.flt gamemenu.flt modmenu.flt _tbox.flt $(OPT_FLT) 
    3131 
    3232%.o: %.c 
     
    4949        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    5050 
     51_tbox.elf: ../gui_tbox.o 
     52        @echo \-\> $@ 
     53        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
     54 
    5155benchm.elf: simple_module.o ../gui_bench.o 
    5256        @echo \-\> $@ 
     
    6569        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    6670 
    67 tetris.elf: ../gui_tetris.o 
     71tetris.elf: simple_game.o ../gui_tetris.o 
    6872        @echo \-\> $@ 
    6973        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    7074 
    71 snake.elf: ../gui_snake.o 
     75snake.elf: simple_game.o ../gui_snake.o 
    7276        @echo \-\> $@ 
    7377        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    7478 
    7579sokoban.elf: ../gui_sokoban.o