Changeset 1542


Ignore:
Timestamp:
01/11/12 12:58:46 (17 months ago)
Author:
philmoz
Message:

Add feature to allow modules to have their own config file, module specific settings can be stored in the module config file instead of the core CHDK config file further improving module separation from the core CHDK code. Modules can be extended with new settings without changing core CHDK.
Config settings moved to the zebra, edge overlay, grids, text reader and sokoban modules.
Config version updated to 2.0.
Module config files are saved in A/CHDK/MODULES/CFG.

Update of GetMemInfo? and GetExMemInfo? so the functions are always available (for the module_inspector module).

Updated makeexport to save the symbol hash values to be loaded by elf2flt. This means the hash function code is only in one place to ensure consistency.

Location:
branches/reyalp-flt
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • branches/reyalp-flt/core/Makefile

    r1534 r1542  
    106106module_exportlist.h: $(topdir)tools/makeexport$(EXE) module_exportlist.c 
    107107        @echo $< \-\> $@ 
    108         $(topdir)tools/makeexport$(EXE) module_exportlist.c module_exportlist.h modules/exportlist.txt 
     108        $(topdir)tools/makeexport$(EXE) module_exportlist.c module_exportlist.h modules/exportlist.txt module_hashlist.h 
    109109 
    110110flt.h: $(topdir)tools/elf2flt/flt.h 
  • branches/reyalp-flt/core/conf.c

    r1539 r1542  
    1717//------------------------------------------------------------------- 
    1818#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 = { MAKE_API_VERSION(1,1) }; 
     19#define CONF_MAGICK_VALUE   (0x33204741) 
     20 
     21//------------------------------------------------------------------- 
     22Conf conf = { MAKE_API_VERSION(2,0) }; 
    4223 
    4324int state_shooting_progress = SHOOTING_PROGRESS_NONE; 
     
    142123         shooting_video_bitrate_change(conf.video_bitrate); 
    143124        } 
    144         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! 
     125        //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! 
    145126} 
    146127 
     
    177158    CONF_INFO( 29, conf.batt_icon_color,        CONF_DEF_VALUE, cl:COLOR_WHITE, NULL), 
    178159    CONF_INFO( 30, conf.menu_color,             CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL), 
    179     CONF_INFO( 31, conf.reader_color,           CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_GREY, COLOR_WHITE), NULL), 
     160    //CONF_INFO( 31, conf.reader_color,           CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_GREY, COLOR_WHITE), NULL), 
    180161    CONF_INFO( 32, conf.ricoh_ca1_mode,         CONF_DEF_VALUE, i:0, NULL), 
    181162    CONF_INFO( 33, conf.flashlight,             CONF_DEF_VALUE, i:0, NULL), 
     
    185166    CONF_INFO( 36, conf.raw_prefix,             CONF_DEF_VALUE, i:RAW_PREFIX_CRW, NULL), 
    186167    CONF_INFO( 37, conf.raw_ext,                CONF_DEF_VALUE, i:DEFAULT_RAW_EXT, NULL), 
    187     CONF_INFO( 38, conf.reader_file,            CONF_CHAR_PTR,   ptr:"A/CHDK/BOOKS/README.TXT", NULL), 
    188     CONF_INFO( 39, conf.reader_pos,             CONF_DEF_VALUE, i:0, NULL), 
    189     CONF_INFO( 40, conf.sokoban_level,          CONF_DEF_VALUE, i:0, NULL), 
     168    //CONF_INFO( 38, conf.reader_file,            CONF_CHAR_PTR,   ptr:"A/CHDK/BOOKS/README.TXT", NULL), 
     169    //CONF_INFO( 39, conf.reader_pos,             CONF_DEF_VALUE, i:0, NULL), 
     170    //CONF_INFO( 40, conf.sokoban_level,          CONF_DEF_VALUE, i:0, NULL), 
    190171    CONF_INFO( 41, conf.show_clock,             CONF_DEF_VALUE, i:2, NULL), 
    191172    CONF_INFO( 42, conf.clock_pos,              CONF_OSD_POS_PTR,   ptr:&def_clock_pos , NULL), 
    192     CONF_INFO( 43, conf.reader_autoscroll,      CONF_DEF_VALUE, i:0, NULL), 
    193     CONF_INFO( 44, conf.reader_autoscroll_delay,CONF_DEF_VALUE, i:5, NULL), 
    194     CONF_INFO( 45, conf.reader_rbf_file,        CONF_CHAR_PTR,   ptr:"", NULL), 
    195     CONF_INFO( 46, conf.reader_codepage,        CONF_DEF_VALUE, i:FONT_CP_WIN, NULL), 
     173    //CONF_INFO( 43, conf.reader_autoscroll,      CONF_DEF_VALUE, i:0, NULL), 
     174    //CONF_INFO( 44, conf.reader_autoscroll_delay,CONF_DEF_VALUE, i:5, NULL), 
     175    //CONF_INFO( 45, conf.reader_rbf_file,        CONF_CHAR_PTR,   ptr:"", NULL), 
     176    //CONF_INFO( 46, conf.reader_codepage,        CONF_DEF_VALUE, i:FONT_CP_WIN, NULL), 
    196177    CONF_INFO( 47, conf.splash_show,            CONF_DEF_VALUE, i:1, NULL), 
    197178    CONF_INFO( 48, conf.histo_color2,           CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_RED, COLOR_WHITE), NULL), 
    198179    CONF_INFO( 49, conf.zebra_draw,             CONF_DEF_VALUE, i:0, NULL), 
    199     CONF_INFO( 50, conf.zebra_mode,             CONF_DEF_VALUE, i:ZEBRA_MODE_BLINKED_2, NULL), 
    200     CONF_INFO( 51, conf.zebra_restore_screen,   CONF_DEF_VALUE, i:1, NULL), 
    201     CONF_INFO( 52, conf.zebra_restore_osd,      CONF_DEF_VALUE, i:1, NULL), 
    202     CONF_INFO( 53, conf.zebra_over,             CONF_DEF_VALUE, i:1, NULL), 
    203     CONF_INFO( 54, conf.zebra_under,            CONF_DEF_VALUE, i:0, NULL), 
    204     CONF_INFO( 55, conf.zebra_color,            CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_RED, COLOR_RED), NULL), 
    205     CONF_INFO( 56, conf.zebra_draw_osd,         CONF_DEF_VALUE, i:ZEBRA_DRAW_HISTO, NULL), 
     180    //CONF_INFO( 50, conf.zebra_mode,             CONF_DEF_VALUE, i:ZEBRA_MODE_BLINKED_2, NULL), 
     181    //CONF_INFO( 51, conf.zebra_restore_screen,   CONF_DEF_VALUE, i:1, NULL), 
     182    //CONF_INFO( 52, conf.zebra_restore_osd,      CONF_DEF_VALUE, i:1, NULL), 
     183    //CONF_INFO( 53, conf.zebra_over,             CONF_DEF_VALUE, i:1, NULL), 
     184    //CONF_INFO( 54, conf.zebra_under,            CONF_DEF_VALUE, i:0, NULL), 
     185    //CONF_INFO( 55, conf.zebra_color,            CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_RED, COLOR_RED), NULL), 
     186    //CONF_INFO( 56, conf.zebra_draw_osd,         CONF_DEF_VALUE, i:ZEBRA_DRAW_HISTO, NULL), 
    206187    CONF_INFO( 57, conf.user_menu_as_root,      CONF_DEF_VALUE, i:0, NULL), 
    207188    CONF_INFO( 58, conf.zoom_value,             CONF_DEF_VALUE, i:ZOOM_SHOW_X, NULL), 
    208189    CONF_INFO( 59, conf.use_zoom_mf,            CONF_DEF_VALUE, i:0, NULL), 
    209190    CONF_INFO( 60, conf.raw_save_first_only,    CONF_DEF_VALUE, i:0, NULL), 
    210     CONF_INFO( 61, conf.reader_wrap_by_words,   CONF_DEF_VALUE, i:1, NULL), 
     191    //CONF_INFO( 61, conf.reader_wrap_by_words,   CONF_DEF_VALUE, i:1, NULL), 
    211192    CONF_INFO( 62, conf.menu_symbol_enable,     CONF_DEF_VALUE, i:1, NULL), 
    212193    CONF_INFO( 63, conf.alt_mode_button,        CONF_DEF_VALUE, i:KEY_PRINT, conf_change_alt_mode_button), 
     
    216197    CONF_INFO( 67, conf.alt_prevent_shutdown,   CONF_DEF_VALUE, i:ALT_PREVENT_SHUTDOWN_ALT, conf_update_prevent_shutdown), 
    217198    CONF_INFO( 68, conf.show_grid_lines,        CONF_DEF_VALUE, i:0, NULL), 
    218     CONF_INFO( 69, conf.grid_lines_file,        CONF_CHAR_PTR,   ptr:"", NULL), 
     199    //CONF_INFO( 69, conf.grid_lines_file,        CONF_CHAR_PTR,   ptr:"", NULL), 
    219200    CONF_INFO( 70, conf.raw_nr,                 CONF_DEF_VALUE, i:NOISE_REDUCTION_AUTO_CANON, NULL), 
    220     CONF_INFO( 71, conf.grid_force_color,       CONF_DEF_VALUE, i:0, NULL), 
    221     CONF_INFO( 72, conf.grid_color,             CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL), 
     201    //CONF_INFO( 71, conf.grid_force_color,       CONF_DEF_VALUE, i:0, NULL), 
     202    //CONF_INFO( 72, conf.grid_color,             CONF_DEF_VALUE, cl:MAKE_COLOR(COLOR_BG, COLOR_FG), NULL), 
    222203 
    223204    CONF_INFO( 80, conf.dof_subj_dist_as_near_limit,CONF_DEF_VALUE, i:0, NULL), 
     
    280261     
    281262    CONF_INFO(126, conf.clear_bracket,          CONF_DEF_VALUE, i:1, NULL), 
    282     CONF_INFO(127, conf.zebra_multichannel,     CONF_DEF_VALUE, i:0, NULL), 
     263    //CONF_INFO(127, conf.zebra_multichannel,     CONF_DEF_VALUE, i:0, NULL), 
    283264 
    284265    CONF_INFO(128, conf.nd_filter_state,        CONF_DEF_VALUE, i:0, NULL), 
     
    348329    CONF_INFO(187, conf.edge_overlay_enable,    CONF_DEF_VALUE, i:0, NULL), 
    349330    CONF_INFO(188, conf.edge_overlay_thresh,    CONF_DEF_VALUE, i:60, NULL), 
    350     CONF_INFO(189, conf.edge_overlay_color,     CONF_DEF_VALUE, cl:0x66, NULL), 
     331    //CONF_INFO(189, conf.edge_overlay_color,     CONF_DEF_VALUE, cl:0x66, NULL), 
    351332    CONF_INFO(190, conf.synch_enable,           CONF_DEF_VALUE, i:0, NULL), 
    352333    CONF_INFO(191, conf.synch_delay_enable,     CONF_DEF_VALUE, i:0, NULL), 
     
    381362    CONF_INFO(220, conf.temperature_unit,              CONF_DEF_VALUE, i:0, NULL), 
    382363    CONF_INFO(221, conf.clear_zoom_override,         CONF_DEF_VALUE, i:1, NULL),                         
    383     CONF_INFO(222, conf.edge_overlay_play,    CONF_DEF_VALUE, i:0, NULL), 
    384     CONF_INFO(223, conf.edge_overlay_pano,              CONF_DEF_VALUE, i:0, NULL), 
    385     CONF_INFO(224, conf.edge_overlay_zoom,                CONF_DEF_VALUE, i:1, NULL), 
     364    //CONF_INFO(222, conf.edge_overlay_play,    CONF_DEF_VALUE, i:0, NULL), 
     365    //CONF_INFO(223, conf.edge_overlay_pano,              CONF_DEF_VALUE, i:0, NULL), 
     366    //CONF_INFO(224, conf.edge_overlay_zoom,                CONF_DEF_VALUE, i:1, NULL), 
    386367    CONF_INFO(225, conf.raw_cache,              CONF_DEF_VALUE, i:0, NULL), 
    387368    CONF_INFO(226, conf.dng_raw,                CONF_DEF_VALUE, i:0, conf_change_dng), 
     
    400381        CONF_INFO(239, conf.debug_propcase_page,     CONF_DEF_VALUE, i:0, NULL), 
    401382        CONF_INFO(240, conf.debug_misc_vals_show,     CONF_DEF_VALUE, i:0, NULL), 
    402         CONF_INFO(241, conf.edge_overlay_filter,     CONF_DEF_VALUE, i:0, NULL), 
    403         CONF_INFO(242, conf.edge_overlay_show,     CONF_DEF_VALUE, i:0, NULL), 
    404     CONF_INFO(243, conf.edge_overlay_pano_overlap,   CONF_DEF_VALUE, i:30, NULL), 
     383        //CONF_INFO(241, conf.edge_overlay_filter,     CONF_DEF_VALUE, i:0, NULL), 
     384        //CONF_INFO(242, conf.edge_overlay_show,     CONF_DEF_VALUE, i:0, NULL), 
     385    //CONF_INFO(243, conf.edge_overlay_pano_overlap,   CONF_DEF_VALUE, i:30, NULL), 
    405386 
    406387    // Touch screen U/I overrides 
     
    561542 
    562543//------------------------------------------------------------------- 
    563 void conf_load_defaults() { 
     544void config_load_defaults(const ConfInfo *confinfo, int conf_num, void (*info_func)(unsigned short id)) 
     545{ 
    564546    register int i; 
    565547 
    566     for (i=0; i<CONF_NUM; ++i) { 
    567         switch (conf_info[i].type) { 
     548    for (i=0; i<conf_num; ++i) { 
     549        switch (confinfo[i].type) { 
    568550            case CONF_DEF_VALUE: 
    569                 memcpy(conf_info[i].var, &(conf_info[i].i), conf_info[i].size); 
     551                memcpy(confinfo[i].var, &(confinfo[i].i), confinfo[i].size); 
    570552                break; 
    571553            case CONF_INT_PTR: 
     
    573555            case CONF_OSD_POS_PTR: 
    574556            case CONF_CHAR_PTR: 
    575                 memcpy(conf_info[i].var, conf_info[i].ptr, conf_info[i].size); 
     557                memcpy(confinfo[i].var, confinfo[i].ptr, confinfo[i].size); 
    576558                break; 
    577559        } 
    578         conf_info_func(conf_info[i].id); 
    579         //if (conf_info[i].func) { 
    580         //    conf_info[i].func(); 
    581         //} 
    582     } 
     560        if (info_func) info_func(confinfo[i].id); 
     561    } 
     562} 
     563 
     564void conf_load_defaults() 
     565{ 
     566    config_load_defaults(&conf_info[0], CONF_NUM, conf_info_func); 
    583567} 
    584568 
     
    592576} ConfInfoSave; 
    593577 
    594 void conf_save() { 
     578void config_save(const ConfInfo *conf_info, char *filename, int conf_num) 
     579{ 
    595580    static const long t=CONF_MAGICK_VALUE; 
    596581    register int i; 
    597     int fd; 
    598     char *buf = umalloc(sizeof(t) + CONF_NUM*sizeof(ConfInfoSave) + sizeof(conf)); 
    599     char *p=buf; 
    600  
    601     fd = open(CONF_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0777);  
    602     if (fd>=0){ 
     582     
     583    int size = sizeof(t) + conf_num * sizeof(ConfInfoSave); 
     584    for (i=0; i<conf_num; i++) size += conf_info[i].size; 
     585 
     586    char *buf = umalloc(size); 
     587    char *p = buf; 
     588 
     589    int fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0777);  
     590    if (fd >= 0) 
     591    { 
    603592        memcpy(p, &t, sizeof(t)); 
    604         p+=sizeof(t); 
    605         for (i=0; i<CONF_NUM; ++i) { 
     593        p += sizeof(t); 
     594        for (i=0; i<conf_num; ++i) 
     595        { 
    606596            ((ConfInfoSave*)p)->id   = conf_info[i].id; 
    607597            ((ConfInfoSave*)p)->size = conf_info[i].size; 
     
    617607} 
    618608 
    619 //------------------------------------------------------------------- 
    620 void conf_restore() { 
     609void conf_save() 
     610{ 
     611    config_save(&conf_info[0], CONF_FILE, CONF_NUM); 
     612} 
     613 
     614//------------------------------------------------------------------- 
     615void config_restore(const ConfInfo *confinfo, char *filename, int conf_num, void (*init_defaults)(), void (*info_func)(unsigned short id)) 
     616{ 
    621617    int fd, rcnt, i; 
    622618    unsigned short id, size; 
    623619    char *buf; 
    624     int offs; 
     620    int offs, old_ver; 
    625621    struct stat st; 
    626622 
    627     conf_init_defaults(); 
    628  
    629     conf_load_defaults(); 
    630  
    631     if( stat(CONF_FILE,&st) != 0 || st.st_size < sizeof(int)) 
     623    if (init_defaults) init_defaults(); 
     624    config_load_defaults(confinfo, conf_num, info_func); 
     625 
     626    if( stat(filename,&st) != 0 || st.st_size < sizeof(int)) 
    632627        return; 
    633628 
     
    635630        return; 
    636631 
    637     fd = open(CONF_FILE, O_RDONLY, 0777);  
     632    fd = open(filename, O_RDONLY, 0777);  
    638633    if( fd < 0 ) { 
    639634        ufree(buf); 
     
    648643        return; 
    649644    } 
     645 
    650646    offs=sizeof(int); 
    651647    while (1) { 
     
    660656        offs += sizeof(short); 
    661657 
    662         for (i=0; i<CONF_NUM; ++i) { 
    663             if (conf_info[i].id==id && conf_info[i].size==size) { 
     658        for (i=0; i<conf_num; ++i) { 
     659            if (confinfo[i].id==id && ((confinfo[i].size==size) || ((confinfo[i].size == 4) && (size == 2)))) { 
    664660                if (offs + size <= rcnt) { 
    665                    memcpy(conf_info[i].var, buf+offs, size); 
    666                    conf_info_func(conf_info[i].id); 
     661                   memcpy(confinfo[i].var, buf+offs, size); 
     662                   if (size == 2) 
     663                   { 
     664                       // Fix color value 
     665                       int *p = (int*)confinfo[i].var; 
     666                       *p = (((*p >> 8) & 0xFF) << 16) | (*p &0xFF); 
     667                   } 
     668                   if (info_func) info_func(confinfo[i].id); 
    667669                } 
    668670                offs += size; 
     
    670672            } 
    671673        } 
    672         if (i == CONF_NUM) { // unknown id, just skip data 
     674        if (i == conf_num) { // unknown id, just skip data 
    673675            offs += size; 
    674676        } 
     
    677679    // clear any "clear on restart" values 
    678680    clear_values(); 
     681} 
     682 
     683void conf_restore() 
     684{ 
     685    config_restore(&conf_info[0], CONF_FILE, CONF_NUM, conf_init_defaults, conf_info_func); 
    679686} 
    680687 
  • branches/reyalp-flt/core/curves.c

    r1536 r1542  
    469469  if ( !API_VERSION_MATCH_REQUIREMENT( camera_sensor.api_version, 1, 0 ) ) 
    470470         return 1; 
    471   if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 1, 0 ) ) 
     471  if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 
    472472         return 1; 
    473473 
  • branches/reyalp-flt/core/edgeoverlay.c

    r1536 r1542  
    1313#include "module_exportlist.h" 
    1414 
     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//------------------------------------------------------------------- 
    1541 
    1642// the way we save edge overlays on their own... 
     
    6187            memset(edgebuf->ptr, 0, edgebuf->ptrLen); 
    6288    } 
    63     if (conf.edge_overlay_filter && (smbuf == NULL)) 
     89    if (econf.edge_overlay_filter && (smbuf == NULL)) 
    6490    { 
    6591        smbuf = (unsigned char*)malloc(viewport_byte_width*3); 
     
    6995        { 
    7096            // Disable filtering if we do not have enough memory for it 
    71             conf.edge_overlay_filter = 0; 
     97            econf.edge_overlay_filter = 0; 
    7298        } 
    7399    } 
     
    197223        { 
    198224            fsm_state = EDGE_FROZEN;    // switch to "edge overlay frozen"-mode 
    199             if (conf.edge_overlay_zoom) 
     225            if (econf.edge_overlay_zoom) 
    200226            { 
    201227                shooting_set_zoom(zoom); 
     
    305331    memset(edgebuf->ptr + slice*compressed_slice, 0, compressed_slice); 
    306332 
    307     if (conf.edge_overlay_filter) 
     333    if (econf.edge_overlay_filter) 
    308334    { 
    309335        // Prefill smbuf with three lines of avergae-filtered data. 
     
    327353        shutter_fullpress |= kbd_is_key_pressed(KEY_SHOOT_FULL); 
    328354 
    329         if (conf.edge_overlay_filter) 
     355        if (econf.edge_overlay_filter) 
    330356        { 
    331357            // We need to shift up our smbuf one line, 
     
    423449//  care so much about performance, you can enable it. 
    424450// 
    425 //    if (conf.edge_overlay_filter) 
     451//    if (econf.edge_overlay_filter) 
    426452//    { 
    427453//        // Here we do basic filtering on the detected edges. 
     
    458484//                            bv_get(edgebuf, (y+1)*viewport_width + (x+1)); 
    459485// 
    460 //                        if (!conf.edge_overlay_show) 
     486//                        if (!econf.edge_overlay_show) 
    461487//                        { 
    462488//                            if (sum >= 5)    // if we have at least 5 neighboring edges 
     
    486512    int x_off, y_off; 
    487513 
    488     const color cl = conf.edge_overlay_color; 
     514    const color cl = econf.edge_overlay_color; 
    489515    const int y_slice_min = viewport_yoffset+camera_screen.edge_hmargin+ slice   *slice_height; 
    490516    const int y_slice_max = viewport_yoffset+camera_screen.edge_hmargin+(slice+1)*slice_height; 
     
    517543                    const int aspect_correct_x_off = x_off; 
    518544                    const int bEdge = bv_get(edgebuf, y_edgebuf + x); 
    519                     const int bDraw = bEdge || (draw_get_pixel(aspect_correct_x_off, y_off) == conf.edge_overlay_color); 
    520                     const color cl = bEdge ? conf.edge_overlay_color : 0; 
     545                    const int bDraw = bEdge || (draw_get_pixel(aspect_correct_x_off, y_off) == econf.edge_overlay_color); 
     546                    const color cl = bEdge ? econf.edge_overlay_color : 0; 
    521547                    if (bEdge || bDraw) 
    522548                        draw_pixel(aspect_correct_x_off, y_off, cl); 
     
    576602    const int x_max = (viewport_width - 2); 
    577603 
    578     switch(conf.edge_overlay_pano) 
     604    switch(econf.edge_overlay_pano) 
    579605    { 
    580606    case 0:     // pano off 
     
    583609        break; 
    584610    case 1:     // pano from left to right 
    585         xoffset = -x_max*(100-conf.edge_overlay_pano_overlap)/100; 
     611        xoffset = -x_max*(100-econf.edge_overlay_pano_overlap)/100; 
    586612        break; 
    587613    case 2:     // pano from top to bottom 
    588         yoffset = -y_max*(100-conf.edge_overlay_pano_overlap)/100; 
     614        yoffset = -y_max*(100-econf.edge_overlay_pano_overlap)/100; 
    589615        break; 
    590616    case 3:     // pano from right to left 
    591         xoffset = x_max*(100-conf.edge_overlay_pano_overlap)/100; 
     617        xoffset = x_max*(100-econf.edge_overlay_pano_overlap)/100; 
    592618        break; 
    593619    case 4:     // pano from bottom to top 
    594         yoffset = y_max*(100-conf.edge_overlay_pano_overlap)/100; 
     620        yoffset = y_max*(100-econf.edge_overlay_pano_overlap)/100; 
    595621        break; 
    596622    case 5:     // free mode 
     
    630656    const int bHalfPress = kbd_is_key_pressed(KEY_SHOOT_HALF); 
    631657    const int bPlayMode = (mode_get() & MODE_MASK) == MODE_PLAY; 
    632     const int bPanoramaMode = (conf.edge_overlay_pano != 0); 
    633     const int bNeedHalfPress = (conf.edge_overlay_show != 1); 
    634     const int bDisplayInPlay = (conf.edge_overlay_play == 1); 
     658    const int bPanoramaMode = (econf.edge_overlay_pano != 0); 
     659    const int bNeedHalfPress = (econf.edge_overlay_show != 1); 
     660    const int bDisplayInPlay = (econf.edge_overlay_play == 1); 
    635661    const int bGuiModeNone = (gui_get_mode() == GUI_MODE_NONE); 
    636662    const int bGuiModeAlt = (gui_get_mode() == GUI_MODE_ALT); 
     
    766792static CMenuItem edge_overlay_submenu_items[] = { 
    767793    MENU_ITEM(0x5c,LANG_MENU_EDGE_OVERLAY_ENABLE,   MENUITEM_BOOL,              &conf.edge_overlay_enable, 0 ), 
    768     MENU_ITEM(0x5c,LANG_MENU_EDGE_FILTER,           MENUITEM_BOOL,              &conf.edge_overlay_filter, 0 ), 
    769     MENU_ENUM2(0x5f,LANG_MENU_EDGE_PANO,            &conf.edge_overlay_pano,    gui_edge_pano_modes ), 
    770     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) ), 
    771     MENU_ITEM(0x5c,LANG_MENU_EDGE_SHOW,             MENUITEM_BOOL,              &conf.edge_overlay_show, 0 ), 
     794    MENU_ITEM(0x5c,LANG_MENU_EDGE_FILTER,           MENUITEM_BOOL,              &econf.edge_overlay_filter, 0 ), 
     795    MENU_ENUM2(0x5f,LANG_MENU_EDGE_PANO,            &econf.edge_overlay_pano,    gui_edge_pano_modes ), 
     796    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) ), 
     797    MENU_ITEM(0x5c,LANG_MENU_EDGE_SHOW,             MENUITEM_BOOL,              &econf.edge_overlay_show, 0 ), 
    772798    MENU_ITEM(0x5e,LANG_MENU_EDGE_OVERLAY_TRESH,    MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.edge_overlay_thresh, MENU_MINMAX(0, 255) ), 
    773     MENU_ITEM(0x65,LANG_MENU_EDGE_OVERLAY_COLOR,    MENUITEM_COLOR_FG,          &conf.edge_overlay_color, 0 ), 
    774     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 
     799    MENU_ITEM(0x65,LANG_MENU_EDGE_OVERLAY_COLOR,    MENUITEM_COLOR_FG,          &econf.edge_overlay_color, 0 ), 
     800    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 
    775801    MENU_ITEM(0x33,LANG_MENU_EDGE_SAVE,                     MENUITEM_PROC,                      gui_menuproc_edge_save, 0 ), 
    776     MENU_ITEM(0x5c,LANG_MENU_EDGE_ZOOM,             MENUITEM_BOOL,              &conf.edge_overlay_zoom, 0 ), 
     802    MENU_ITEM(0x5c,LANG_MENU_EDGE_ZOOM,             MENUITEM_BOOL,              &econf.edge_overlay_zoom, 0 ), 
    777803    MENU_ITEM(0x33,LANG_MENU_EDGE_LOAD,                     MENUITEM_PROC,                      gui_menuproc_edge_load, 0 ), 
    778804    MENU_ITEM(0x51,LANG_MENU_BACK,                  MENUITEM_UP, 0, 0 ), 
     
    820846  if ( !API_VERSION_MATCH_REQUIREMENT( camera_sensor.api_version, 1, 0 ) ) 
    821847         return 1; 
    822   if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 1, 0 ) ) 
     848  if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 
    823849         return 1; 
     850 
     851  conf_info[0].cl = MAKE_COLOR(0, COLOR_BLUE); 
     852  config_restore(&conf_info[0], "A/CHDK/MODULES/CFG/edgeovr.cfg", sizeof(conf_info)/sizeof(conf_info[0]), 0, 0); 
    824853 
    825854  return 0; 
     
    838867        //              because even if we turn off edgeovr we could turn on back and 
    839868        //              should get same content. 
    840   return 0; 
     869    config_save(&conf_info[0], "A/CHDK/MODULES/CFG/edgeovr.cfg", sizeof(conf_info)/sizeof(conf_info[0])); 
     870    reset_edge_overlay(); 
     871    return 0; 
    841872} 
    842873 
     
    850881  module_idx=moduleidx; 
    851882 
    852   gui_activate_sub_menu(&edge_overlay_submenu, -1); 
     883  gui_activate_sub_menu(&edge_overlay_submenu, module_idx); 
    853884 
    854885  return 0; 
  • branches/reyalp-flt/core/gui.c

    r1537 r1542  
    592592    MENU_ITEM(0x65,LANG_MENU_VIS_HISTO_BORDER,        MENUITEM_COLOR_FG,  &conf.histo_color2, 0 ), 
    593593    MENU_ITEM(0x65,LANG_MENU_VIS_HISTO_MARKERS,       MENUITEM_COLOR_BG,  &conf.histo_color2, 0 ), 
    594     MENU_ITEM(0x65,LANG_MENU_VIS_ZEBRA_UNDER,         MENUITEM_COLOR_BG,  &conf.zebra_color, 0 ), 
    595     MENU_ITEM(0x65,LANG_MENU_VIS_ZEBRA_OVER,          MENUITEM_COLOR_FG,  &conf.zebra_color, 0 ), 
     594    //MENU_ITEM(0x65,LANG_MENU_VIS_ZEBRA_UNDER,         MENUITEM_COLOR_BG,  &conf.zebra_color, 0 ),         // moved to zebra menu 
     595    //MENU_ITEM(0x65,LANG_MENU_VIS_ZEBRA_OVER,          MENUITEM_COLOR_FG,  &conf.zebra_color, 0 ),         // moved to zebra menu 
    596596    MENU_ITEM(0x65,LANG_MENU_VIS_BATT_ICON,           MENUITEM_COLOR_FG,  &conf.batt_icon_color, 0 ), 
    597597    MENU_ITEM(0x65,LANG_MENU_VIS_SPACE_ICON,          MENUITEM_COLOR_FG,  &conf.space_color, 0 ), 
     
    605605    MENU_ITEM(0x65,LANG_MENU_VIS_MENU_SYMBOL_TEXT,    MENUITEM_COLOR_FG,  &conf.menu_symbol_color, 0 ), 
    606606    MENU_ITEM(0x65,LANG_MENU_VIS_MENU_SYMBOL_BKG,     MENUITEM_COLOR_BG,  &conf.menu_symbol_color, 0 ), 
    607     MENU_ITEM(0x65,LANG_MENU_VIS_READER_TEXT,         MENUITEM_COLOR_FG,  &conf.reader_color, 0 ), 
    608     MENU_ITEM(0x65,LANG_MENU_VIS_READER_BKG,          MENUITEM_COLOR_BG,  &conf.reader_color, 0 ), 
     607    //MENU_ITEM(0x65,LANG_MENU_VIS_READER_TEXT,         MENUITEM_COLOR_FG,  &conf.reader_color, 0 ),        // moved to text reader menu 
     608    //MENU_ITEM(0x65,LANG_MENU_VIS_READER_BKG,          MENUITEM_COLOR_BG,  &conf.reader_color, 0 ),        // moved to text reader menu 
    609609    MENU_ITEM(0x65,LANG_MENU_VIS_OSD_OVERRIDE,         MENUITEM_COLOR_FG,  &conf.osd_color_override, 0 ), 
    610610    MENU_ITEM(0x65,LANG_MENU_VIS_OSD_OVERRIDE_BKG,     MENUITEM_COLOR_BG,  &conf.osd_color_override, 0 ), 
  • branches/reyalp-flt/core/gui_debug.c

    r1536 r1542  
    197197  if ( !API_VERSION_MATCH_REQUIREMENT( camera_info.api_version, 1, 0 ) ) 
    198198         return 1; 
    199   if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 1, 0 ) ) 
     199  if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 
    200200         return 1; 
    201201 
  • branches/reyalp-flt/core/gui_fselect.c

    r1539 r1542  
    14161416  if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) ) 
    14171417          return 1; 
    1418   if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 1, 0 ) ) 
     1418  if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 
    14191419         return 1; 
    14201420 
  • branches/reyalp-flt/core/gui_games.c

    r1536 r1542  
    5454     return 1; 
    5555 
    56   if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 1, 0 ) ) 
     56  if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 
    5757         return 1; 
    5858 
  • branches/reyalp-flt/core/gui_grid.c

    r1536 r1542  
    1212#include "modules.h" 
    1313#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}; 
    1431 
    1532//------------------------------------------------------------------- 
     
    158175            } 
    159176            close(fd); 
    160             strcpy(conf.grid_lines_file, fn); 
     177            strcpy(gconf.grid_lines_file, fn); 
    161178        } else { 
    162             conf.grid_lines_file[0] = 0; 
     179            gconf.grid_lines_file[0] = 0; 
    163180        } 
    164181 
     
    178195            switch (ptr->type) { 
    179196                case GRID_ELEM_LINE: 
    180                     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); 
    181198                    break; 
    182199                case GRID_ELEM_RECT: 
    183                     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); 
    184201                    break; 
    185202                case GRID_ELEM_FILLED_RECT: 
    186                     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)); 
    187204                    break; 
    188205                case GRID_ELEM_ELLIPSE: 
    189                     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); 
    190207                    break; 
    191208                case GRID_ELEM_FILLED_ELLIPSE: 
    192                     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)); 
    193210                    break; 
    194211            } 
     
    205222} 
    206223void gui_grid_lines_load(int arg) { 
    207     module_fselect_init(LANG_STR_SELECT_GRID_FILE, conf.grid_lines_file, "A/CHDK/GRIDS", gui_grid_lines_load_selected); 
     224    module_fselect_init(LANG_STR_SELECT_GRID_FILE, gconf.grid_lines_file, "A/CHDK/GRIDS", gui_grid_lines_load_selected); 
    208225} 
    209226 
     
    214231    MENU_ITEM(0x0,(int)grid_title,              MENUITEM_TEXT,      0, 0 ), 
    215232    MENU_ITEM(0x0,(int)"",                      MENUITEM_SEPARATOR, 0, 0 ), 
    216     MENU_ITEM(0x5c,LANG_MENU_GRID_FORCE_COLOR,  MENUITEM_BOOL,      &conf.grid_force_color, 0 ), 
    217     MENU_ITEM(0x65,LANG_MENU_GRID_COLOR_LINE,   MENUITEM_COLOR_FG,  &conf.grid_color, 0 ), 
    218     MENU_ITEM(0x65,LANG_MENU_GRID_COLOR_FILL,   MENUITEM_COLOR_BG,  &conf.grid_color, 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 ), 
    219236    MENU_ITEM(0x51,LANG_MENU_BACK,              MENUITEM_UP, 0, 0 ), 
    220237    {0} 
     
    259276  if ( !API_VERSION_MATCH_REQUIREMENT( camera_sensor.api_version, 1, 0 ) ) 
    260277         return 1; 
    261   if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 1, 0 ) ) 
     278  if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 
    262279         return 1; 
    263280 
    264   grid_lines_load(conf.grid_lines_file); 
     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); 
    265285 
    266286  return 0; 
     
    275295int _module_unloader() 
    276296{ 
     297    config_save(&conf_info[0], "A/CHDK/MODULES/CFG/grids.cfg", sizeof(conf_info)/sizeof(conf_info[0])); 
    277298    grid_lines_free_data(); 
    278299    return 0; 
  • branches/reyalp-flt/core/gui_read.c

    r1536 r1542  
    1515#include "module_load.h" 
    1616 
     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//------------------------------------------------------------------- 
     45 
    1746extern void gui_read_kbd_process_menu_btn(); 
    1847void gui_read_kbd_process(); 
     
    5786//------------------------------------------------------------------- 
    5887static void gui_read_draw_scroll_indicator() { 
    59     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 
    6089} 
    6190 
     
    6493    static struct STD_stat   st; 
    6594    read_file = safe_open(file, O_RDONLY, 0777); 
    66     if (strcmp(file, conf.reader_file)!=0) { 
    67         conf.reader_pos = 0; 
    68         strcpy(conf.reader_file, file); 
     95    if (strcmp(file, rconf.reader_file)!=0) { 
     96        rconf.reader_pos = 0; 
     97        strcpy(rconf.reader_file, file); 
    6998    } 
    7099    read_on_screen = 0; 
    71100    read_file_size = (read_file>=0 && safe_stat((char*)file, &st)==0)?st.st_size:0; 
    72     if (read_file_size<=conf.reader_pos) { 
    73         conf.reader_pos = 0; 
     101    if (read_file_size<=rconf.reader_pos) { 
     102        rconf.reader_pos = 0; 
    74103    } 
    75104    pause = 0; 
     
    85114 
    86115    draw_filled_rect(0, 0, camera_screen.width-1, y-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 
    87     draw_filled_rect(0, y, camera_screen.width-1, camera_screen.height-1, MAKE_COLOR(BG_COLOR(conf.reader_color), BG_COLOR(conf.reader_color))); 
     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))); 
    88117 
    89118    gui_read_draw_scroll_indicator(); 
     
    95124//------------------------------------------------------------------- 
    96125static void read_goto_next_line() { 
    97     draw_filled_rect(xx, yy, x+w-1, yy+rbf_font_height()-1, MAKE_COLOR(BG_COLOR(conf.reader_color), BG_COLOR(conf.reader_color))); 
     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))); 
    98127    xx  = x; 
    99128    yy += rbf_font_height(); 
     
    107136//------------------------------------------------------------------- 
    108137void gui_read_draw(int enforce_redraw) { 
    109     if (conf.reader_autoscroll && !pause && get_tick_count()-last_time >= conf.reader_autoscroll_delay*1000 && (conf.reader_pos+read_on_screen)<read_file_size) { 
    110         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; 
    111140        read_to_draw = 1; 
    112141    } 
     
    116145        xx=x; yy=y; 
    117146 
    118         lseek(read_file, conf.reader_pos, SEEK_SET); 
     147        lseek(read_file, rconf.reader_pos, SEEK_SET); 
    119148        read_on_screen=0; 
    120149 
     
    124153                 read_goto_next_line(); 
    125154                 if (yy < y+h) 
    126                      draw_filled_rect(x, yy, x+w-1, y+h-1, MAKE_COLOR(BG_COLOR(conf.reader_color), BG_COLOR(conf.reader_color))); 
     155                     draw_filled_rect(x, yy, x+w-1, y+h-1, MAKE_COLOR(BG_COLOR(rconf.reader_color), BG_COLOR(rconf.reader_color))); 
    127156                 break; 
    128157            } 
     
    141170                        // no break here 
    142171                    default: 
    143                         if (conf.reader_wrap_by_words) { 
     172                        if (rconf.reader_wrap_by_words) { 
    144173                            if (buffer[i] == ' ') { 
    145174                                new_word = 1; 
     
    171200                            continue; 
    172201                        } 
    173                         xx+=rbf_draw_char(xx, yy, buffer[i], conf.reader_color); 
     202                        xx+=rbf_draw_char(xx, yy, buffer[i], rconf.reader_color); 
    174203                        break; 
    175204                } 
     
    183212        } 
    184213     
    185         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); 
    186215        buffer[camera_screen.width/FONT_WIDTH]=0; 
    187216        draw_txt_string((camera_screen.ts_button_border/FONT_WIDTH), 0, buffer, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline 
     
    192221            n=i*read_on_screen/read_file_size;           // bar height 
    193222            if (n<20) n=20; 
    194             i=(i-n)*conf.reader_pos/read_file_size;   // top pos 
     223            i=(i-n)*rconf.reader_pos/read_file_size;   // top pos 
    195224            draw_filled_rect(x+w+6+2, y+1,   x+w+6+6, y+1+i,   MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 
    196225            draw_filled_rect(x+w+6+2, y+i+n, x+w+6+6, y+h-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 
     
    215244        case KEY_UP: 
    216245        case KEY_LEFT: 
    217             if (conf.reader_pos>0) { 
    218                 conf.reader_pos -= 45*15; 
    219                 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; 
    220249                read_to_draw = 1; 
    221250            } 
     
    226255        case KEY_RIGHT: 
    227256        case KEY_SHOOT_HALF: 
    228             if ((conf.reader_pos+read_on_screen)<read_file_size) { 
    229                 conf.reader_pos += read_on_screen; 
     257            if ((rconf.reader_pos+read_on_screen)<read_file_size) { 
     258                rconf.reader_pos += read_on_screen; 
    230259                read_to_draw = 1; 
    231260            } 
     
    270299static void gui_draw_read_selected(const char *fn) { 
    271300    if (fn) { 
    272         if (!rbf_load(conf.reader_rbf_file)) 
     301        if (!rbf_load(rconf.reader_rbf_file)) 
    273302            rbf_load_from_8x16(current_font); 
    274         rbf_set_codepage(conf.reader_codepage); 
     303        rbf_set_codepage(rconf.reader_codepage); 
    275304        gui_set_mode(&GUI_MODE_READ); 
    276305        gui_read_init(fn); 
     
    282311 
    283312void gui_draw_read(int arg) { 
    284     module_fselect_init_w_mode(LANG_STR_SELECT_TEXT_FILE, conf.reader_file, "A/CHDK/BOOKS", gui_draw_read_selected, 1); 
     313    module_fselect_init_w_mode(LANG_STR_SELECT_TEXT_FILE, rconf.reader_file, "A/CHDK/BOOKS", gui_draw_read_selected, 1); 
    285314    void gui_fselect_set_key_redraw(int n); 
    286315    //gui_fselect_set_key_redraw(1);    @tsv 
     
    289318void gui_draw_read_last(int arg) { 
    290319    struct STD_stat st; 
    291     if (safe_stat(conf.reader_file,&st) == 0) { 
    292         gui_draw_read_selected(conf.reader_file); 
     320    if (safe_stat(rconf.reader_file,&st) == 0) { 
     321        gui_draw_read_selected(rconf.reader_file); 
    293322    } else { 
    294323        gui_draw_read(arg); 
     
    298327static void gui_draw_rbf_selected(const char *fn) { 
    299328    if (fn) { 
    300         strcpy(conf.reader_rbf_file, fn); 
     329        strcpy(rconf.reader_rbf_file, fn); 
    301330    } 
    302331} 
    303332 
    304333void gui_draw_load_rbf(int arg) { 
    305     module_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.reader_rbf_file, "A/CHDK/FONTS", gui_draw_rbf_selected); 
     334    module_fselect_init(LANG_STR_SELECT_FONT_FILE, rconf.reader_rbf_file, "A/CHDK/FONTS", gui_draw_rbf_selected); 
    306335} 
    307336 
     
    311340    MENU_ITEM(0x35,LANG_MENU_READ_OPEN_LAST,          MENUITEM_PROC,    gui_draw_read_last, 0 ), 
    312341    MENU_ITEM(0x35,LANG_MENU_READ_SELECT_FONT,        MENUITEM_PROC,    gui_draw_load_rbf, 0 ), 
    313     MENU_ENUM2(0x5f,LANG_MENU_READ_CODEPAGE,          &conf.reader_codepage, gui_reader_codepage_cps ), 
    314     MENU_ITEM(0x5c,LANG_MENU_READ_WORD_WRAP,          MENUITEM_BOOL,    &conf.reader_wrap_by_words, 0 ), 
    315     MENU_ITEM(0x5c,LANG_MENU_READ_AUTOSCROLL,         MENUITEM_BOOL,    &conf.reader_autoscroll, 0 ), 
    316     MENU_ITEM(0x5f,LANG_MENU_READ_AUTOSCROLL_DELAY,   MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.reader_autoscroll_delay, MENU_MINMAX(0, 60) ), 
     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 ), 
    317348    MENU_ITEM(0x51,LANG_MENU_BACK,                    MENUITEM_UP, 0, 0 ), 
    318349    {0} 
     
    344375  if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
    345376     return 1; 
     377 
    346378  if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) ) 
    347379          return 1; 
    348   if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 1, 0 ) ) 
     380  if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 
    349381         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); 
    350385 
    351386  return 0; 
     
    360395int _module_unloader() 
    361396{ 
    362   GUI_MODE_READ.magicnum = 0;   //sanity clean to prevent accidentaly assign/restore guimode to unloaded module  
    363  
    364   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; 
    365402} 
    366403 
  • branches/reyalp-flt/core/gui_sokoban.c

    r1536 r1542  
    1313#include "module_load.h" 
    1414 
     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}; 
     27 
    1528void gui_module_menu_kbd_process(); 
    1629void gui_sokoban_kbd_process(); 
     
    1932gui_handler GUI_MODE_SOKOBAN =  
    2033    /*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 }; 
    21  
    2234 
    2335//------------------------------------------------------------------- 
     
    206218     
    207219    free(buf); 
    208     conf.sokoban_level = lvl; 
     220    sconf.sokoban_level = lvl; 
    209221    moves = 0; 
    210222    sokoban_undo_reset(); 
     
    224236//------------------------------------------------------------------- 
    225237static void sokoban_next_level() { 
    226     if (++conf.sokoban_level >= num_levels) conf.sokoban_level = 0; 
    227     sokoban_set_level(conf.sokoban_level); 
     238    if (++sconf.sokoban_level >= num_levels) sconf.sokoban_level = 0; 
     239    sokoban_set_level(sconf.sokoban_level); 
    228240    need_redraw_all = 1; 
    229241} 
     
    322334        return 0; 
    323335    } 
    324     else if(conf.sokoban_level >= num_levels) { 
    325         conf.sokoban_level = 0; 
     336    else if(sconf.sokoban_level >= num_levels) { 
     337        sconf.sokoban_level = 0; 
    326338    } 
    327339    cell_size = camera_screen.height/FIELD_HEIGHT; 
    328     sokoban_set_level(conf.sokoban_level); 
     340    sokoban_set_level(sconf.sokoban_level); 
    329341        // if the file is no longer readable, set_level will set this 
    330342    if(!num_levels) { 
     
    335347    gui_set_mode(&GUI_MODE_SOKOBAN); 
    336348    return 1; 
    337 } 
    338  
    339 int basic_module_init() { 
    340   return gui_sokoban_init(); 
    341349} 
    342350 
     
    375383        case KEY_ERASE: 
    376384        case KEY_DISPLAY: 
    377             sokoban_set_level(conf.sokoban_level); 
     385            sokoban_set_level(sconf.sokoban_level); 
    378386            need_redraw_all = 1; 
    379387            break; 
     
    426434        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); 
    427435 
    428         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); 
    429437        draw_string(camera_screen.ts_button_border+cell_size*FIELD_WIDTH+2, 8, str, MAKE_COLOR(SCREEN_COLOR, COLOR_WHITE)); 
    430438        sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_MOVES), moves); 
     
    448456        gui_default_kbd_process_menu_btn(); 
    449457        module_async_unload(module_idx); 
     458} 
     459 
     460 
     461// =========  MODULE INIT ================= 
     462 
     463int module_idx=-1; 
     464 
     465/***************** BEGIN OF AUXILARY PART ********************* 
     466  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     467 **************************************************************/ 
     468 
     469void* MODULE_EXPORT_LIST[] = { 
     470        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     471        /* 1 */ (void*)0 
     472                }; 
     473 
     474 
     475//--------------------------------------------------------- 
     476// PURPOSE:   Bind module symbols with chdk.  
     477//              Required function 
     478// PARAMETERS: pointer to chdk list of export 
     479// RETURN VALUE: 1 error, 0 ok 
     480//--------------------------------------------------------- 
     481int _module_loader( unsigned int* chdk_export_list ) 
     482{ 
     483  if ( chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     484     return 1; 
     485 
     486  if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) ) 
     487          return 1; 
     488 
     489  config_restore(&conf_info[0], "A/CHDK/MODULES/CFG/sokoban.cfg", sizeof(conf_info)/sizeof(conf_info[0]), 0, 0); 
     490 
     491  return 0; 
     492} 
     493 
     494 
     495//--------------------------------------------------------- 
     496// PURPOSE: Finalize module operations (close allocs, etc) 
     497// RETURN VALUE: 0-ok, 1-fail 
     498//--------------------------------------------------------- 
     499int _module_unloader() 
     500{ 
     501    config_save(&conf_info[0], "A/CHDK/MODULES/CFG/sokoban.cfg", sizeof(conf_info)/sizeof(conf_info[0])); 
     502    return 0; 
     503} 
     504 
     505 
     506//--------------------------------------------------------- 
     507// PURPOSE: Default action for simple modules (direct run) 
     508// NOTE: Please comment this function if no default action and this library module 
     509//--------------------------------------------------------- 
     510int _module_run(int moduleidx, int argn, int* arguments) 
     511{ 
     512  module_idx=moduleidx; 
     513 
     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  } 
     521  if ( ! rv ) 
     522        module_async_unload(moduleidx);         // fail to init - "unload me" 
     523 
     524  return 0; 
    450525} 
    451526 
  • branches/reyalp-flt/core/main.c

    r1522 r1542  
    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 
  • branches/reyalp-flt/core/module_exportlist.c

    r1537 r1542  
    4141 
    4242// ** SECTION 1: DEFINE UNDECLARED EXPORTED ITEMS 
    43  
    44 #ifndef CAM_FIRMWARE_MEMINFO 
    45 #define GetMemInfo 0 
    46 #endif 
    47 #if !defined(OPT_EXMEM_MALLOC) 
    48 #define GetExMemInfo 0 
    49 #endif 
    5043 
    5144 
     
    8477char COLOR__EXPORTEDSYM_HISTO_RG_PLAY = COLOR_HISTO_RG_PLAY ; 
    8578 
    86  
    8779/* EXPORTED_DEFINES_END */ 
    8880 
     81 
    8982// ** SECTION 3: LIST OF EXPORTED SYMBOLS (pointer to function/variable) 
    90 //    1. DO NOT CHANGE ORDER AND DO NOT DELETE EXISTED ENTRIES 
    91 //    2. VARIABLE conf SHOULDN'T EXIST IN THE LIST TO KEEP ISOLATION. USE set|get_chdk_conf|get_chdk_conf_ptr INSTEAD 
    92 //      STOPLIST: conf, open, opendir, closedir, rewinddir, readdir, stat 
     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 
    9388 
    9489#if 0 
    95  
    96 void* CHDK_EXPORT_LIST[] = { 
    97             (void*)EXPORTLIST_MAGIC_NUMBER, 
    98             (void*)EXPORTLIST_LAST_IDX, 
    99  
     90{ 
    10091                        module_async_unload, 
    10192                        module_set_flags, 
     
    325316                        module_tbox_get_version, 
    326317                        module_tbox_run, 
    327 }; 
    328  
     318 
     319            config_save, 
     320            config_restore, 
     321} 
    329322#endif 
    330323 
     324// Symbol hash table for resolving exported symbol references 
    331325sym_hash symbol_hash_table[] = 
    332326{ 
  • branches/reyalp-flt/core/module_load.c

    r1536 r1542  
    158158{ 
    159159    // binary search (first entry is magic number & entry count) 
    160     int min = 1, max = EXPORTLIST_LAST_IDX-1; 
     160    int min = 1, max = EXPORTLIST_LAST_IDX; 
    161161    do 
    162162    { 
     
    186186 
    187187        if (importaddress == 0) return 0; 
    188  
    189          // //@tsv todo: if (*relocbuf>=flat->reloc_start) error_out_of_bound 
    190                 //// No such symbol to import 
    191                 //if ( importidx<2 || importidx>EXPORTLIST_LAST_IDX ) 
    192                 //      return 0; 
    193  
    194                 //// Empty symbol - module could only if import such symbol manually 
    195                 //if ( CHDK_EXPORT_LIST[importidx]==0 ) 
    196                 //      return 0; 
    197188 
    198189                *ptr += (int)importaddress;  //(uint32_t)CHDK_EXPORT_LIST[importidx]; 
  • branches/reyalp-flt/core/modules.c

    r1539 r1542  
    288288    module_dng_semaphore |= owner; 
    289289 
    290     module_load_generic((void**)&libgrids, MODULE_NAME_GRIDS, bind_module_dng, 0); 
     290    module_load_generic((void**)&libdng, MODULE_NAME_DNG, bind_module_dng, 0); 
    291291 
    292292    if (libdng == 0) 
  • branches/reyalp-flt/core/modules/Makefile

    r1537 r1542  
    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 gamemenu.flt modmenu.flt  _tbox.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 
     
    5252        @echo \-\> $@ 
    5353        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    54  
    5554 
    5655benchm.elf: simple_module.o ../gui_bench.o 
     
    7877        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    7978 
    80 sokoban.elf: simple_game.o ../gui_sokoban.o 
     79sokoban.elf: ../gui_sokoban.o 
    8180        @echo \-\> $@ 
    8281        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
  • branches/reyalp-flt/core/modules/module_inspector.c

    r1537 r1542  
    99 
    1010extern int basic_module_init(); 
    11 void (*_getmeminfo)(void*) = 0; 
    12 void (*_getexmeminfo)(void*) = 0; 
    1311 
    1412/***************** BEGIN OF AUXILARY PART ********************* 
     
    3533  if ( !API_VERSION_MATCH_REQUIREMENT( gui_version.common_api, 1, 0 ) ) 
    3634          return 1; 
    37  
    38   _getmeminfo = module_find_symbol_address(MODULESYM_GETMEMINFO); 
    39   _getexmeminfo = module_find_symbol_address(MODULESYM_GETEXMEMINFO); 
    4035 
    4136  return 0; 
     
    184179        draw_txt_string(1, 4+showidx,  "SET-redraw, DISP-unload_all, MENU-exit",       MAKE_COLOR(SCREEN_COLOR, COLOR_WHITE)); 
    185180 
    186                 // Simple platform-dependend part [not always GetMemInfo exits] 
    187181        cam_meminfo meminfo; 
    188                 if (_getmeminfo) { 
    189  
    190                         memset(&meminfo,0,sizeof(meminfo)); 
    191                 _getmeminfo(&meminfo); 
    192  
    193             gui_mem_info("MEM", &meminfo, showidx); 
    194  
    195             showidx += 3; 
    196                 } 
    197                 if (_getexmeminfo) { 
    198  
    199                         memset(&meminfo,sizeof(meminfo),0); 
    200                 _getexmeminfo(&meminfo); 
    201  
     182 
     183        // Display Canon heap memory info 
     184        // amount of data displayed may vary depending on GetMemInfo implementation 
     185        memset(&meminfo,0,sizeof(meminfo)); 
     186        GetMemInfo(&meminfo); 
     187        gui_mem_info("MEM", &meminfo, showidx); 
     188        showidx += 3; 
     189 
     190        // Display EXMEM memory info (only if enabled) 
     191        memset(&meminfo,0,sizeof(meminfo)); 
     192        if (GetExMemInfo(&meminfo)) 
     193        { 
    202194            gui_mem_info("EXMEM", &meminfo, showidx); 
    203195                } 
  • branches/reyalp-flt/core/zebra.c

    r1536 r1542  
    1313#include "modules.h" 
    1414#include "module_exportlist.h" 
     15 
     16//------------------------------------------------------------------- 
     17 
     18typedef struct 
     19{ 
     20    color zebra_color;    // under/over 
     21    int zebra_mode; 
     22    int zebra_restore_screen; 
     23    int zebra_restore_osd; 
     24    int zebra_over; 
     25    int zebra_under; 
     26    int zebra_draw_osd; 
     27    int zebra_multichannel; 
     28} ZebraConf; 
     29 
     30ZebraConf zconf; 
     31 
     32static ConfInfo conf_info[] = { 
     33    CONF_INFO( 1, zconf.zebra_color,            CONF_DEF_VALUE, cl:0, NULL), 
     34    CONF_INFO( 2, zconf.zebra_mode,             CONF_DEF_VALUE, i:ZEBRA_MODE_BLINKED_2, NULL), 
     35    CONF_INFO( 3, zconf.zebra_restore_screen,   CONF_DEF_VALUE, i:1, NULL), 
     36    CONF_INFO( 4, zconf.zebra_restore_osd,      CONF_DEF_VALUE, i:1, NULL), 
     37    CONF_INFO( 5, zconf.zebra_over,             CONF_DEF_VALUE, i:1, NULL), 
     38    CONF_INFO( 6, zconf.zebra_under,            CONF_DEF_VALUE, i:0, NULL), 
     39    CONF_INFO( 7, zconf.zebra_draw_osd,         CONF_DEF_VALUE, i:ZEBRA_DRAW_HISTO, NULL), 
     40    CONF_INFO( 8, zconf.zebra_multichannel,     CONF_DEF_VALUE, i:0, NULL), 
     41}; 
    1542 
    1643//------------------------------------------------------------------- 
     
    166193//------------------------------------------------------------------- 
    167194static void gui_osd_draw_zebra_osd() { 
    168     switch (conf.zebra_draw_osd) { 
     195    switch (zconf.zebra_draw_osd) { 
    169196        case ZEBRA_DRAW_NONE: 
    170197            break; 
     
    219246int gui_osd_draw_zebra(int show) { 
    220247    unsigned int v, s, x, y, f, over; 
    221     color cl_under = BG_COLOR(conf.zebra_color), cl_over = FG_COLOR(conf.zebra_color); 
     248    color cl_under = BG_COLOR(zconf.zebra_color), cl_over = FG_COLOR(zconf.zebra_color); 
    222249    static int need_restore=0; 
    223250    int viewport_height; 
     
    274301        viewport_xoffset = vid_get_viewport_xoffset(); 
    275302        viewport_yoffset = vid_get_viewport_yoffset(); 
    276     switch (conf.zebra_mode) { 
     303    switch (zconf.zebra_mode) { 
    277304        case ZEBRA_MODE_ZEBRA_1: 
    278305            f = 4; 
     
    302329                } 
    303330        int step_x, step_v, sy, sx; 
    304         over = 255-conf.zebra_over; 
    305             if (conf.zebra_multichannel) {step_x=2; step_v=6;} else {step_x=1; step_v=3;} 
     331        over = 255-zconf.zebra_over; 
     332            if (zconf.zebra_multichannel) {step_x=2; step_v=6;} else {step_x=1; step_v=3;} 
    306333            for (y=viewport_yoffset, v=viewport_image_offset; y<viewport_yoffset+viewport_height; ++y) { 
    307334                sy=y*camera_screen.buffer_width; 
     
    316343                    yy = img_buf[v+1]; 
    317344                    s=sy+sx*2; 
    318                     if (conf.zebra_multichannel) { 
     345                    if (zconf.zebra_multichannel) { 
    319346                        uu = (signed char)img_buf[v]; 
    320347                        vv = (signed char)img_buf[v+2]; 
    321348                        sel=0; 
    322                         if (!((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) { 
     349                        if (!((zconf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || zconf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) { 
    323350                            if (clip8(((yy<<12) +           vv*5743 + 2048)>>12)>over) sel  = 4; // R 
    324351                            if (clip8(((yy<<12) - uu*1411 - vv*2925 + 2048)>>12)>over) sel |= 2; // G 
     
    328355                        buf[s+2]=buf[s+3]=cls[sel]; 
    329356                    } 
    330                     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; 
    331                     else buf[s]=buf[s+1]=(yy>over)?cl_over:(yy<conf.zebra_under)?cl_under:COLOR_TRANSPARENT; 
     357                    else if (((zconf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || zconf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) buf[s]=buf[s+1]=COLOR_TRANSPARENT; 
     358                    else buf[s]=buf[s+1]=(yy>over)?cl_over:(yy<zconf.zebra_under)?cl_under:COLOR_TRANSPARENT; 
    332359                    if (buf[s] != COLOR_TRANSPARENT && !zebra_drawn) zebra_drawn = 1; 
    333360#if ZEBRA_CANONOSD_BORDER_RESTORE                         
    334361                        if(get_cur_buf(s)!=COLOR_TRANSPARENT) buf[s]=get_cur_buf(s);  
    335                         if(conf.zebra_multichannel && get_cur_buf(s+1)!=COLOR_TRANSPARENT) buf[s+1]=get_cur_buf(s+1);  
     362                        if(zconf.zebra_multichannel && get_cur_buf(s+1)!=COLOR_TRANSPARENT) buf[s+1]=get_cur_buf(s+1);  
    336363#else 
    337364                        if(cur_buf[s]!=COLOR_TRANSPARENT) buf[s]=cur_buf[s]; 
    338                         if(conf.zebra_multichannel && cur_buf[s+1]!=COLOR_TRANSPARENT) buf[s+1]=cur_buf[s+1]; 
     365                        if(zconf.zebra_multichannel && cur_buf[s+1]!=COLOR_TRANSPARENT) buf[s+1]=cur_buf[s+1]; 
    339366#endif 
    340367 
     
    351378        // if zebra was drawn during previous call of this function 
    352379        if (need_restore) { 
    353             if (conf.zebra_restore_screen || conf.zebra_restore_osd) { 
     380            if (zconf.zebra_restore_screen || zconf.zebra_restore_osd) { 
    354381                draw_restore(); 
    355382            } else {  // clear buf[] of zebra, only leave Canon OSD 
     
    380407            need_restore=0; 
    381408        } 
    382         return !(conf.zebra_restore_screen && conf.zebra_restore_osd); 
     409        return !(zconf.zebra_restore_screen && zconf.zebra_restore_osd); 
    383410    // if zebra was drawn 
    384411    } else { 
     
    399426int gui_osd_draw_zebra(int show) { 
    400427    unsigned int v, s, x, y, f, over; 
    401     color cl_under = BG_COLOR(conf.zebra_color), cl_over = FG_COLOR(conf.zebra_color); 
     428    color cl_under = BG_COLOR(zconf.zebra_color), cl_over = FG_COLOR(zconf.zebra_color); 
    402429    static int need_restore=0; 
    403430    int viewport_height; 
     
    471498    } 
    472499    viewport_height = vid_get_viewport_height(); 
    473     switch (conf.zebra_mode) { 
     500    switch (zconf.zebra_mode) { 
    474501        case ZEBRA_MODE_ZEBRA_1: 
    475502            f = 4; 
     
    495522    if (f) { 
    496523        int step_x, step_v; 
    497         over = 255-conf.zebra_over; 
    498             if (conf.zebra_multichannel) {step_x=2; step_v=6;} else {step_x=1; step_v=3;} 
     524        over = 255-zconf.zebra_over; 
     525            if (zconf.zebra_multichannel) {step_x=2; step_v=6;} else {step_x=1; step_v=3;} 
    499526            s = aspOffset; 
    500527            for (y=1, v=0; y<=viewport_height; ++y) { 
     
    506533                                                                                 
    507534                    yy = img_buf[v+1]; 
    508                     if (conf.zebra_multichannel) { 
     535                    if (zconf.zebra_multichannel) { 
    509536                        uu = (signed char)img_buf[v]; 
    510537                        vv = (signed char)img_buf[v+2]; 
    511538                        sel=0; 
    512                         if (!((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) { 
     539                        if (!((zconf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || zconf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) { 
    513540                            if (clip8(((yy<<12) +           vv*5743 + 2048)>>12)>over) sel  = 4; // R 
    514541                            if (clip8(((yy<<12) - uu*1411 - vv*2925 + 2048)>>12)>over) sel |= 2; // G 
     
    517544                        buf[s]=buf[s+1]=cls[sel]; 
    518545                    } 
    519                     else if (((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) buf[s]=COLOR_TRANSPARENT; 
    520                     else buf[s]=(yy>over)?cl_over:(yy<conf.zebra_under)?cl_under:COLOR_TRANSPARENT; 
     546                    else if (((zconf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || zconf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) buf[s]=COLOR_TRANSPARENT; 
     547                    else buf[s]=(yy>over)?cl_over:(yy<zconf.zebra_under)?cl_under:COLOR_TRANSPARENT; 
    521548                    if (buf[s] != COLOR_TRANSPARENT && !zebra_drawn) zebra_drawn = 1; 
    522549                    if (mrec) { 
     
    524551#if ZEBRA_CANONOSD_BORDER_RESTORE                         
    525552                        if(get_cur_buf(s)!=COLOR_TRANSPARENT) buf[s]=get_cur_buf(s);  
    526                         if(conf.zebra_multichannel && get_cur_buf(s+1)!=COLOR_TRANSPARENT) buf[s+1]=get_cur_buf(s+1);  
     553                        if(zconf.zebra_multichannel && get_cur_buf(s+1)!=COLOR_TRANSPARENT) buf[s+1]=get_cur_buf(s+1);  
    527554#else 
    528555                        if(cur_buf[s]!=COLOR_TRANSPARENT) buf[s]=cur_buf[s]; 
    529                         if(conf.zebra_multichannel && cur_buf[s+1]!=COLOR_TRANSPARENT) buf[s+1]=cur_buf[s+1]; 
     556                        if(zconf.zebra_multichannel && cur_buf[s+1]!=COLOR_TRANSPARENT) buf[s+1]=cur_buf[s+1]; 
    530557#endif 
    531558                    } 
     
    543570        // if zebra was drawn during previous call of this function 
    544571        if (need_restore) { 
    545             if (conf.zebra_restore_screen || conf.zebra_restore_osd) { 
     572            if (zconf.zebra_restore_screen || zconf.zebra_restore_osd) { 
    546573                draw_restore(); 
    547574            } else {  // clear buf[] of zebra, only leave Canon OSD 
     
    570597            need_restore=0; 
    571598        } 
    572         return !(conf.zebra_restore_screen && conf.zebra_restore_osd); 
     599        return !(zconf.zebra_restore_screen && zconf.zebra_restore_osd); 
    573600    // if zebra was drawn 
    574601    } else { 
     
    589616 
    590617void cb_zebra_restore_screen() { 
    591     if (!conf.zebra_restore_screen) 
    592         conf.zebra_restore_osd = 0; 
     618    if (!zconf.zebra_restore_screen) 
     619        zconf.zebra_restore_osd = 0; 
    593620} 
    594621 
    595622void cb_zebra_restore_osd() { 
    596     if (conf.zebra_restore_osd) 
    597         conf.zebra_restore_screen = 1; 
     623    if (zconf.zebra_restore_osd) 
     624        zconf.zebra_restore_screen = 1; 
    598625} 
    599626 
     
    602629static CMenuItem zebra_submenu_items[] = { 
    603630    MENU_ITEM(0x5c,LANG_MENU_ZEBRA_DRAW,              MENUITEM_BOOL,                            &conf.zebra_draw, 0 ), 
    604     MENU_ENUM2(0x5f,LANG_MENU_ZEBRA_MODE,             &conf.zebra_mode, gui_zebra_mode_modes ), 
    605     MENU_ITEM(0x58,LANG_MENU_ZEBRA_UNDER,             MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.zebra_under,   MENU_MINMAX(0, 32) ), 
    606     MENU_ITEM(0x57,LANG_MENU_ZEBRA_OVER,              MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.zebra_over,    MENU_MINMAX(0, 32) ), 
    607     MENU_ITEM(0x28,LANG_MENU_ZEBRA_RESTORE_SCREEN,    MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,      &conf.zebra_restore_screen,     cb_zebra_restore_screen ), 
    608     MENU_ITEM(0x5c,LANG_MENU_ZEBRA_RESTORE_OSD,       MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,      &conf.zebra_restore_osd,        cb_zebra_restore_osd ), 
    609     MENU_ENUM2(0x5f,LANG_MENU_ZEBRA_DRAW_OVER,        &conf.zebra_draw_osd, gui_zebra_draw_osd_modes ), 
    610     MENU_ITEM(0x5c,LANG_MENU_ZEBRA_MULTICHANNEL,      MENUITEM_BOOL,                            &conf.zebra_multichannel, 0 ), 
     631    MENU_ENUM2(0x5f,LANG_MENU_ZEBRA_MODE,             &zconf.zebra_mode, gui_zebra_mode_modes ), 
     632    MENU_ITEM(0x58,LANG_MENU_ZEBRA_UNDER,             MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &zconf.zebra_under,   MENU_MINMAX(0, 32) ), 
     633    MENU_ITEM(0x57,LANG_MENU_ZEBRA_OVER,              MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &zconf.zebra_over,    MENU_MINMAX(0, 32) ), 
     634    MENU_ITEM(0x28,LANG_MENU_ZEBRA_RESTORE_SCREEN,    MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,      &zconf.zebra_restore_screen,     cb_zebra_restore_screen ), 
     635    MENU_ITEM(0x5c,LANG_MENU_ZEBRA_RESTORE_OSD,       MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,      &zconf.zebra_restore_osd,        cb_zebra_restore_osd ), 
     636    MENU_ENUM2(0x5f,LANG_MENU_ZEBRA_DRAW_OVER,        &zconf.zebra_draw_osd, gui_zebra_draw_osd_modes ), 
     637    MENU_ITEM(0x5c,LANG_MENU_ZEBRA_MULTICHANNEL,      MENUITEM_BOOL,                            &zconf.zebra_multichannel, 0 ), 
     638    MENU_ITEM(0x65,LANG_MENU_VIS_ZEBRA_UNDER,         MENUITEM_COLOR_BG,  &zconf.zebra_color, 0 ), 
     639    MENU_ITEM(0x65,LANG_MENU_VIS_ZEBRA_OVER,          MENUITEM_COLOR_FG,  &zconf.zebra_color, 0 ), 
    611640    MENU_ITEM(0x51,LANG_MENU_BACK,                    MENUITEM_UP, 0, 0 ), 
    612641    {0} 
     
    650679     return 1; 
    651680 
    652   if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 1, 0 ) ) 
     681  if ( !API_VERSION_MATCH_REQUIREMENT( conf.api_version, 2, 0 ) ) 
    653682         return 1; 
     683 
     684  conf_info[0].cl = MAKE_COLOR(COLOR_RED, COLOR_RED); 
     685  config_restore(&conf_info[0], "A/CHDK/MODULES/CFG/zebra.cfg", sizeof(conf_info)/sizeof(conf_info[0]), 0, 0); 
    654686 
    655687  return 0; 
     
    663695int _module_unloader() 
    664696{ 
     697    config_save(&conf_info[0], "A/CHDK/MODULES/CFG/zebra.cfg", sizeof(conf_info)/sizeof(conf_info[0])); 
    665698    gui_osd_zebra_free(); 
    666699    return 0; 
  • branches/reyalp-flt/include/conf.h

    r1539 r1542  
    113113 
    114114    int zebra_draw; 
    115     int zebra_mode; 
    116     int zebra_restore_screen; 
    117     int zebra_restore_osd; 
    118     int zebra_over; 
    119     int zebra_under; 
    120     int zebra_draw_osd; 
    121     int zebra_multichannel; 
     115    //int zebra_mode; 
     116    //int zebra_restore_screen; 
     117    //int zebra_restore_osd; 
     118    //int zebra_over; 
     119    //int zebra_under; 
     120    //int zebra_draw_osd; 
     121    //int zebra_multichannel; 
    122122 
    123123    OSD_pos histo_pos; 
     
    152152    int menu_select_first_entry; 
    153153    int menu_symbol_enable; 
    154     color reader_color; 
    155     color zebra_color;    // under/over 
    156     color grid_color; 
     154    //color reader_color; 
     155    //color zebra_color;    // under/over 
     156    //color grid_color; 
    157157    color osd_color_override; 
    158158 
     
    163163    char lang_file[100]; 
    164164 
    165     char reader_file[100]; 
    166     int  reader_pos; 
    167     int  reader_autoscroll; 
    168     int  reader_autoscroll_delay; 
    169     char reader_rbf_file[100]; 
    170     int  reader_codepage; 
    171     int  reader_wrap_by_words; 
    172  
    173     int sokoban_level; 
     165    //char reader_file[100]; 
     166    //int  reader_pos; 
     167    //int  reader_autoscroll; 
     168    //int  reader_autoscroll_delay; 
     169    //char reader_rbf_file[100]; 
     170    //int  reader_codepage; 
     171    //int  reader_wrap_by_words; 
     172 
     173    //int sokoban_level; 
    174174 
    175175    int flashlight; 
     
    188188 
    189189    int show_grid_lines; 
    190     char grid_lines_file[100]; 
    191     int grid_force_color; 
     190    //char grid_lines_file[100]; 
     191    //int grid_force_color; 
    192192 
    193193    int video_mode; 
     
    281281 
    282282    int edge_overlay_enable; 
    283     int edge_overlay_filter; 
     283    //int edge_overlay_filter; 
    284284    int edge_overlay_thresh; 
    285     int edge_overlay_zoom;    // shall zoom be set when *edg file is loaded? 
    286     int edge_overlay_pano;    // whether a full press changes back to live mode 
    287     int edge_overlay_pano_overlap;    // overlap in % in pano mode 
    288     int edge_overlay_show;    // whether to show overlay even when no button is pressed 
    289     int edge_overlay_play;    // whether edge overlay is switched on also for play mode 
    290     color edge_overlay_color; 
     285    //int edge_overlay_zoom;    // shall zoom be set when *edg file is loaded? 
     286    //int edge_overlay_pano;    // whether a full press changes back to live mode 
     287    //int edge_overlay_pano_overlap;    // overlap in % in pano mode 
     288    //int edge_overlay_show;    // whether to show overlay even when no button is pressed 
     289    //int edge_overlay_play;    // whether edge overlay is switched on also for play mode 
     290    //color edge_overlay_color; 
    291291 
    292292    int synch_enable; 
     
    363363extern int is_raw_enabled(); 
    364364 
     365//------------------------------------------------------------------- 
     366 
     367typedef struct { 
     368    unsigned short      id; 
     369    unsigned char       size; 
     370    char                type; 
     371    void                *var; 
     372    union { 
     373        void            *ptr; 
     374        int             i; 
     375        color           cl; 
     376    }; 
     377    // Since only a few of the ConfInfo entries have a 'func' it saves space to not store the function addresses in the ConfInfo struct 
     378    // handled in conf_info_func code 
     379    //void                (*func)(); 
     380} ConfInfo; 
     381 
     382#define CONF_INFO(id, param, type, def, func) { id, sizeof( param ), type, &param, {def}/*, func*/ } 
     383 
     384extern void config_save(const ConfInfo *conf_info, char *filename, int conf_num); 
     385extern void config_restore(const ConfInfo *confinfo, char *filename, int conf_num, void (*init_defaults)(), void (*info_func)(unsigned short id)); 
     386 
     387//------------------------------------------------------------------- 
     388 
    365389#endif 
  • branches/reyalp-flt/include/platform.h

    r1514 r1542  
    587587} cam_meminfo; 
    588588 
    589 #if defined(CAM_FIRMWARE_MEMINFO) 
     589// Always included for module_inspector 
    590590extern void GetMemInfo(cam_meminfo*); 
    591 #endif 
     591extern int GetExMemInfo(cam_meminfo*); 
    592592 
    593593#ifdef OPT_EXMEM_MALLOC 
    594 void exmem_malloc_init(void); 
    595 void GetExMemInfo(cam_meminfo*); 
     594extern void exmem_malloc_init(void); 
    596595#endif 
    597596 
  • branches/reyalp-flt/platform/generic/wrappers.c

    r1514 r1542  
    692692// Use suba functions to fill meminfo structure to match firmware GetMemInfo function 
    693693 
    694 void GetExMemInfo(cam_meminfo *camera_meminfo) 
     694int GetExMemInfo(cam_meminfo *camera_meminfo) 
    695695{ 
    696696        extern void suba_getmeminfo(void*, int*, int*, int*, int*, int*, int*); 
     
    702702                    &camera_meminfo->allocated_size, &camera_meminfo->allocated_peak, &camera_meminfo->allocated_count, 
    703703                    &camera_meminfo->free_size, &camera_meminfo->free_block_max_size, &camera_meminfo->free_block_count); 
     704 
     705    return 1;   // return success 
    704706} 
    705707// regular malloc 
     
    711713void free(void *p) { 
    712714    return _free(p); 
     715} 
     716 
     717// Include this for the module_inspector module to simplify symbol export logic 
     718int GetExMemInfo(cam_meminfo *camera_meminfo) 
     719{ 
     720    return 0;   // return failure (not implemented) 
    713721} 
    714722#endif 
     
    747755} 
    748756  
     757void GetMemInfo(cam_meminfo *camera_meminfo) 
     758{ 
    749759#if defined(CAM_FIRMWARE_MEMINFO) 
    750760 
    751761// Use firmware GetMemInfo function to retrieve info about Canon heap memory allocation 
    752762 
    753 void GetMemInfo(cam_meminfo *camera_meminfo) 
    754 { 
    755763#if defined(CAM_DRYOS) 
    756764    // Prior to dryos R39 GetMemInfo returns 9 values, after R39 it returns 10 (all but 1 are used in each case) 
     
    800808#endif 
    801809#endif 
    802 } 
    803  
    804 #endif 
     810 
     811#else   //!defined(CAM_FIRMWARE_MEMINFO) 
     812    // -1 for invalid 
     813    memset(camera_meminfo,0xFF,sizeof(cam_meminfo)); 
     814 
     815    // Calculate largest free block size 
     816        int size, l_size, d; 
     817    char* ptr; 
     818 
     819    size = 16; 
     820    while (1) { 
     821        ptr= malloc(size); 
     822        if (ptr) { 
     823            free(ptr); 
     824            size <<= 1; 
     825        } else 
     826            break; 
     827    } 
     828 
     829    l_size = size; 
     830    size >>= 1; 
     831    d=1024; 
     832    while (d) { 
     833        ptr = malloc(size); 
     834        if (ptr) { 
     835            free(ptr); 
     836            d = l_size-size; 
     837            if (d<0) d=-d; 
     838            l_size = size; 
     839            size += d>>1; 
     840        } else { 
     841            d = size-l_size; 
     842            if (d<0) d=-d; 
     843            l_size = size; 
     844            size -= d>>1; 
     845        } 
     846         
     847    } 
     848 
     849    camera_meminfo->free_block_max_size = size-1; 
     850#endif 
     851} 
     852 
    805853 
    806854//---------------------------------------------------------------------------- 
  • branches/reyalp-flt/tools/elf2flt/myio.c

    r1536 r1542  
    8484 
    8585static char* import_buf=0; 
    86 static char* import_syms[MAX_SYM]; 
    87 static unsigned int import_hash[MAX_SYM]; 
    88 static int import_counts=0; 
     86static char* import_syms[MAX_SYM];          // Symbol names in input file 
     87static unsigned int import_hash[MAX_SYM];   // Symbol hash values in input file 
     88static int import_counts=0;                 // # of symbols found 
    8989static int importfilesize=0; 
    90  
    91 unsigned int hash(unsigned char *str) 
    92 { 
    93     unsigned int hash = 5381; 
    94     int c; 
    95  
    96     while ((c = *str++) != 0) 
    97         hash = ((hash << 5) + hash) ^ c; /* hash * 33 xor c */ 
    98  
    99     return hash; 
    100 } 
    10190 
    10291int load_import(char* importfile) 
     
    137126      return -loaded; 
    138127 
    139         // Parse and check 
     128    // Input file contains symbol hash value (in hex), a space and then the symbol name 
     129        // Parse the input file and build the symbol / hash table 
    140130        char* p=import_buf; 
    141131    char* s=p; 
     
    149139                if (*p==10) { 
    150140                        *p=0; 
    151             import_syms[import_counts] = s; 
    152             import_hash[import_counts] = hash(s); 
     141            unsigned int h; 
     142            sscanf(s,"%x ",&h); 
     143            import_syms[import_counts] = s+9; 
     144            import_hash[import_counts] = h; 
    153145                        import_counts++; 
    154146            s = p + 1; 
     
    156148                } 
    157149                 
    158                 if (!((*p>='A' && *p<='Z') ||  
    159                           (*p>='a' && *p<='z') ||  
    160                           (*p>='0' && *p<='9') ||  
    161                           *p=='_' )) 
    162                 { 
    163                         PRINTERR(stderr,"Found '%c' sym. Import file should contain only symbol names. No spaces or other sym allowed\n",*p); 
    164                         break; 
    165                 } 
    166  
     150                //if (!((*p>='A' && *p<='Z') ||  
     151                //        (*p>='a' && *p<='z') ||  
     152                //        (*p>='0' && *p<='9') ||  
     153                //        *p=='_' )) 
     154                //{ 
     155                //      PRINTERR(stderr,"Found '%c' sym. Import file should contain only symbol names. No spaces or other sym allowed\n",*p); 
     156                //      break; 
     157                //} 
    167158        } 
    168159        if ( FLAG_VERBOSE ) 
     
    171162} 
    172163 
    173 // Return: 0=not_found, >=2 - import_sym_idx 
     164// Return: 0=not_found, otherwise return has value of symbol name 
    174165int find_import_symbol(char* sym) 
    175166{ 
     
    195186} 
    196187 
    197 // Return symbol name by its idx 
     188// Return symbol name by its hash value 
    198189char* get_import_symbol( unsigned symidx ) 
    199190{ 
  • branches/reyalp-flt/tools/makeexport.c

    r1538 r1542  
    3434            hash_vals[i].count++; 
    3535            fprintf(stderr,"Hash collision for 0x%08x (%s and %s)\n",val, sym, hash_vals[i].symbol); 
    36             return; 
     36            exit(-3); 
    3737        } 
    3838    } 
     
    6363    int c; 
    6464 
     65    // djb2 hash algorithm (Dan Bernstein - http://cr.yp.to/djb.html) 
    6566    while ((c = *str++) != 0) 
    6667        hash = ((hash << 5) + hash) ^ c; /* hash * 33 xor c */ 
     
    205206                        cut_export_token(symbol); 
    206207 
    207                         if (num_lines>=2) { 
    208                 unsigned int hash_val = hash(symbol); 
    209                 add_hash(hash_val,full_symbol); 
    210                                 fprintf(out_txt,"%s\x0a",symbol); 
    211                                 for(; size>=0; size--) 
    212                                 { 
    213                                         if ( symbol[size]>='a' && symbol[size]<='z') 
    214                                                 symbol[size]-=0x20; 
    215                                 } 
    216                                 fprintf(out_h,"#define MODULESYM_%-32s 0x%08x\n",symbol,hash_val); 
     208            unsigned int hash_val = hash(symbol); 
     209            add_hash(hash_val,full_symbol); 
     210            fprintf(out_txt,"%08x %s\n",hash_val,symbol); 
     211                        for(; size>=0; size--) 
     212                        { 
     213                                if ( symbol[size]>='a' && symbol[size]<='z') 
     214                                        symbol[size]-=0x20; 
    217215                        } 
     216                        fprintf(out_h,"#define MODULESYM_%-32s 0x%08x\n",symbol,hash_val); 
    218217 
    219218                        num_lines++; 
     
    226225 
    227226    sort_hash(); 
     227    fprintf(out_hash,"// This is an automatically generated file. DO NOT EDIT!\n"); 
    228228    int n; 
    229229    for (n=0; n<hash_idx; n++) 
     
    233233 
    234234        if (num_lines>=1) 
    235                 fprintf(out_h,"\n#define EXPORTLIST_LAST_IDX %d\n\n",num_lines-1); 
     235                fprintf(out_h,"\n#define EXPORTLIST_LAST_IDX %d\n\n",num_lines); 
    236236        else { 
    237                 fprintf(out_h,"#error Malformed export list. Only %d valid records\n\n",num_lines+2); 
     237                fprintf(out_h,"#error Malformed export list. Only %d valid records\n\n",num_lines); 
    238238                exit(-2); 
    239239        } 
Note: See TracChangeset for help on using the changeset viewer.