Changeset 1505


Ignore:
Timestamp:
12/26/11 01:24:43 (18 months ago)
Author:
reyalp
Message:

merge tsvstar module code from reyalp-flt branch, + fixups for r1499, see http://chdk.setepontos.com/index.php?topic=847.msg77690#msg77690 and following posts
NOTE modules in CHDK/MODULES are now required for CHDK to work properly. On multi-partition cards, this goes on the large card.
Adds tetris and snake, originally contributed by elektro255 in http://chdk.setepontos.com/index.php?topic=2925.0

Location:
trunk
Files:
55 edited
28 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/CHDK/Makefile

    r1007 r1505  
    2828clean: 
    2929        rm -f $(GENLUA) 
     30        rm -f MODULES/*.flt 
    3031 
    3132include $(topdir)bottom.inc 
  • trunk/Makefile

    r1487 r1505  
    1111firsub: all 
    1212        mkdir -p  $(topdir)bin 
     13        mkdir -p  $(topdir)CHDK/MODULES 
    1314        cp $(topdir)loader/$(PLATFORM)/main.bin  $(topdir)bin/main.bin 
    1415ifndef NOZERO100K 
     
    4243        mv  $(topdir)bin/main.bin  $(topdir)bin/DISKBOOT.BIN 
    4344endif 
     45        rm -f $(topdir)CHDK/MODULES/* 
     46        cp $(topdir)core/modules/*.flt $(topdir)CHDK/MODULES 
    4447        @echo "**** Firmware creation completed successfully" 
    4548 
     
    8184      endif 
    8285    endif 
     86        zip -9 $(topdir)bin/$(VER)-$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)CHDK/MODULES/* 
    8387        # if COPY_TO is defined then copy this camera/firmware version to the copied firmware version 
    8488        # Define COPY_TO in $(topdir)/platform/$(PLATFORM)/sub/$(PLATFORMSUB)/makefile.inc of the source 
     
    125129        zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)doc/readme.txt  > $(DEVNULL) 
    126130        zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)doc/readme.txt  > $(DEVNULL) 
     131        zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)CHDK/MODULES/*  > $(DEVNULL) 
     132        zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)CHDK/MODULES/*  > $(DEVNULL) 
    127133 
    128134    ifdef PLATFORMOS 
  • trunk/buildconf.inc

    r1395 r1505  
    11#!build time optional components - comment out the features you dont want to have in your build or copy this file to localbuildconf.inc and override settings there 
    22 
    3 OPT_GAME_REVERSI=1 
    4 OPT_GAME_SOKOBAN=1 
    5 OPT_GAME_CONNECT4=1 
    6 OPT_GAME_MASTERMIND=1 
    73OPT_CURVES=1 
    84OPT_TEXTREADER=1 
    9 OPT_CALENDAR=1 
    105OPT_DEBUGGING=1 
    116OPT_EDGEOVERLAY=1 
  • trunk/core/Makefile

    r1465 r1505  
    1010LDOPTS+=-Wl,-N,-Ttext,$(MEMISOSTART) 
    1111 
     12SUBDIRS=modules 
     13 
    1214all: main.bin 
    1315 
     16# Core CHDK flag 
     17CFLAGS+=-DTHIS_IS_CHDK_CORE 
     18 
    1419OPT_OBJS= 
    15 ifdef OPT_GAME_REVERSI 
    16 CFLAGS+=-DOPT_GAME_REVERSI 
    17 OPT_OBJS+=gui_reversi.o 
    18 endif 
    19 ifdef OPT_GAME_SOKOBAN 
    20 CFLAGS+=-DOPT_GAME_SOKOBAN 
    21 OPT_OBJS+=gui_sokoban.o 
    22 endif 
    23 ifdef OPT_GAME_CONNECT4 
    24 CFLAGS+=-DOPT_GAME_CONNECT4 
    25 OPT_OBJS+=gui_4wins.o 
    26 endif 
    27 ifdef OPT_GAME_MASTERMIND 
    28 CFLAGS+=-DOPT_GAME_MASTERMIND 
    29 OPT_OBJS+=gui_mastermind.o 
    30 endif 
    3120ifdef OPT_CURVES 
    3221CFLAGS+=-DOPT_CURVES 
    33 OPT_OBJS+=curves.o 
     22#OPT_OBJS+=curves.o 
    3423endif 
    3524ifdef OPT_TEXTREADER 
    3625CFLAGS+=-DOPT_TEXTREADER 
    37 OPT_OBJS+=gui_read.o  
    38 endif 
    39 ifdef OPT_CALENDAR 
    40 CFLAGS+=-DOPT_CALENDAR 
    41 OPT_OBJS+=gui_calendar.o  
     26#OPT_OBJS+=gui_read.o  
    4227endif 
    4328ifdef OPT_DEBUGGING 
    4429# global in root makefile.inc 
    4530#CFLAGS+=-DOPT_DEBUGGING 
    46 OPT_OBJS+=gui_debug.o gui_bench.o  
     31#OPT_OBJS+=gui_debug.o gui_bench.o  
    4732endif 
    4833ifdef OPT_EDGEOVERLAY 
    4934CFLAGS+=-DOPT_EDGEOVERLAY 
    50 OPT_OBJS+=edgeoverlay.o  
     35#OPT_OBJS+=edgeoverlay.o  
    5136endif 
    5237ifdef OPT_MD_DEBUG 
     
    7257endif 
    7358 
    74 OBJS=entry.o nothumb.o main.o gui_draw.o gui_menu.o gui_palette.o gui_mbox.o \ 
    75      gui_fselect.o gui.o kbd.o action_stack.o conf.o \ 
     59OBJS=entry.o main.o gui_draw.o gui_menu.o gui_mbox.o \ 
     60     gui.o kbd.o action_stack.o conf.o module_wrappers.o module_exportlist.o \ 
    7661     histogram.o gui_batt.o gui_space.o gui_osd.o raw.o \ 
    77      gui_usb.o gui_lang.o gui_mpopup.o gui_grid.o raw_merge.o \ 
     62     gui_usb.o gui_lang.o gui_grid.o modules.o module_load.o\ 
    7863     levent.o shot_histogram.o dng.o bitvector.o console.o $(OPT_OBJS) 
    7964 
     
    11398        rm -f $(OBJS:.o=.d) 
    11499 
     100module_load.o: module_load.c module_load.h module_exportlist.c module_exportlist.h flt.h 
     101 
     102module_exportlist.h: $(topdir)tools/makeexport$(EXE) module_exportlist.c 
     103        @echo $< \-\> $@ 
     104        $(topdir)tools/makeexport$(EXE) module_exportlist.c module_exportlist.h modules/exportlist.txt 
     105 
     106flt.h: $(topdir)tools/elf2flt/flt.h 
     107        @echo $< \-\> $@ 
     108        @echo "//DO NOT EDIT THIS FILE. This is automatic copy of tools/elf2flt/flt.h" > flt.h 
     109        cat $(topdir)tools/elf2flt/flt.h >>flt.h 
     110 
    115111gui_lang.o: gui_lang.c gui_lang.h gui_lang_str.h 
    116112 
  • trunk/core/curves.c

    r727 r1505  
    44#include "raw.h" 
    55 
    6 #ifdef OPT_CURVES 
    7  
     6//#ifdef OPT_CURVES 
     7#if 1 
     8 
     9#include "module_exportlist.h" 
    810#include "curves.h" 
     11 
     12char *conf_curve_file; 
     13int *conf_curve_enable; 
    914 
    1015/* 
     
    101106 
    102107void curve_set_mode(int value) { 
    103         if((value>=0) && (value<=4)) conf.curve_enable=value; 
     108        if((value>=0) && (value<=4)) *conf_curve_enable=value; 
    104109        curve_init_mode(); 
    105110} 
    106111 
    107112void curve_init_mode() { 
    108         switch(conf.curve_enable) { 
     113        switch(*conf_curve_enable) { 
    109114                case 1: // custom - ensure alloc and load conf.curve_file 
    110                         curve_load_data(conf.curve_file,CURVE_CUSTOM); 
     115                        curve_load_data(conf_curve_file,CURVE_CUSTOM); 
    111116                break; 
    112117                case 2: // system - ensure alloc and load syscurve 
     
    116121                break; 
    117122                default: 
    118                         conf.curve_enable = 0; 
     123                        *conf_curve_enable = 0; 
    119124                case 0: // disabled - free 
    120125                        curve_free_data(); 
     
    141146         
    142147        // Loop through picture rows 
    143         for (i=CAM_RAW_ROWS; i;i-=2){ 
     148        for (i=CAM_CHDK_RAW_ROWS; i;i-=2){ 
    144149                // Loop through picture columns  
    145                 for (j=CAM_RAW_ROWPIX; j; j-=8, src+=10){ 
     150                for (j=CAM_CHDK_RAW_ROWPIX; j; j-=8, src+=10){ 
    146151                        pixVal0=((0x3fc&(((unsigned short)(src[1]))<<2)) | (src[0] >> 6)); 
    147152                        pixVal1=((0x3f0&(((unsigned short)(src[0]))<<4)) | (src[3] >> 4)); 
     
    174179            *(src+8) = (unsigned char) ((pixVal0)); //7 (=>0)           } 
    175180                } 
    176                 for (j=CAM_RAW_ROWPIX;j; j-=8, src+=10){ 
     181                for (j=CAM_CHDK_RAW_ROWPIX;j; j-=8, src+=10){ 
    177182                        pixVal0=((0x3fc&(((unsigned short)(src[1]))<<2)) | (src[0] >> 6)); 
    178183                        pixVal1=((0x3f0&(((unsigned short)(src[0]))<<4)) | (src[3] >> 4)); 
     
    237242         
    238243        // Loop through picture rows 
    239         for (i=CAM_RAW_ROWS; i;i-=2){ 
     244        for (i=CAM_CHDK_RAW_ROWS; i;i-=2){ 
    240245                // Loop through picture columns  
    241                 for (j=CAM_RAW_ROWPIX; j; j-=8, src+=10){ 
     246                for (j=CAM_CHDK_RAW_ROWPIX; j; j-=8, src+=10){ 
    242247                        pixVal0=((0x3fc&(((unsigned short)(src[1]))<<2)) | (src[0] >> 6)); 
    243248                        pixVal1=((0x3f0&(((unsigned short)(src[0]))<<4)) | (src[3] >> 4)); 
     
    302307            *(src+8) = (unsigned char) ((pixVal0)); //7 (=>0) 
    303308                } 
    304                 for (j=CAM_RAW_ROWPIX;j; j-=8, src+=10){ 
     309                for (j=CAM_CHDK_RAW_ROWPIX;j; j-=8, src+=10){ 
    305310                        pixVal0=((0x3fc&(((unsigned short)(src[1]))<<2)) | (src[0] >> 6)); 
    306311                        pixVal1=((0x3f0&(((unsigned short)(src[0]))<<4)) | (src[3] >> 4)); 
     
    371376        short EVbias = shooting_get_ev_correction1(); 
    372377 
    373         switch(conf.curve_enable) { 
     378        switch(*conf_curve_enable) { 
    374379                case 0: 
    375380                        break; 
     
    385390                case 2: 
    386391                case 3: // +1EV,  +2EV 
    387                         if (current_curve_type == CURVE_SYSTEM) curveL_apply( conf.curve_enable & 1 ); 
     392                        if (current_curve_type == CURVE_SYSTEM) curveL_apply( *conf_curve_enable & 1 ); 
    388393                        break; 
    389394                case 4:         // Auto DR 
     
    401406} 
    402407 
     408// =========  MODULE INIT ================= 
     409 
     410#include "module_load.h" 
     411 
     412 
     413int module_idx=-1; 
     414 
     415/***************** BEGIN OF AUXILARY PART ********************* 
     416  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     417 **************************************************************/ 
     418 
     419void* MODULE_EXPORT_LIST[] = { 
     420        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     421        /* 1 */ (void*)5, 
     422 
     423                        curve_set_mode, 
     424                        curve_init_mode, 
     425                        curve_apply, 
     426                }; 
     427 
     428 
     429//--------------------------------------------------------- 
     430// PURPOSE:   Bind module symbols with chdk.  
     431//              Required function 
     432// PARAMETERS: pointer to chdk list of export 
     433// RETURN VALUE: 1 error, 0 ok 
     434//--------------------------------------------------------- 
     435int _module_loader( void** chdk_export_list ) 
     436{ 
     437  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     438     return 1; 
     439 
     440  // Safe bind of conf. 
     441  tConfigVal configVal; 
     442  CONF_BIND_STR(185, conf_curve_file); 
     443  CONF_BIND_INT(186, conf_curve_enable ); 
     444 
     445  // Startup initialize 
     446  curve_init_mode(); 
     447 
     448  return 0; 
     449} 
     450 
     451 
     452 
     453//--------------------------------------------------------- 
     454// PURPOSE: Finalize module operations (close allocs, etc) 
     455// RETURN VALUE: 0-ok, 1-fail 
     456//--------------------------------------------------------- 
     457int _module_unloader() 
     458{ 
     459        // This could be happens only if on-load mistake 
     460        // CHDK never unload this library (but load only if needed) 
     461        // Reason: a) curve_set_mode by LUA is not stored anywhere 
     462        //                 b) perfomance reason - to avoid load on each raw_processing 
     463  return 0; 
     464} 
     465 
     466 
     467/******************** Module Information structure ******************/ 
     468 
     469struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     470                                                                        sizeof(struct ModuleInfo), 
     471 
     472                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     473                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     474                                                                        MODULEINFO_FLAG_SYSTEM,         // flag 
     475                                                                        (int32_t)"Curves (dll)",        // Module name 
     476                                                                        1, 0,                                           // Module version 
     477                                                                        (int32_t)"Apply curves to shots. Only 10bit sensor version" 
     478                                                                 }; 
     479 
     480 
     481/*************** END OF AUXILARY PART *******************/ 
     482 
     483 
    403484#endif 
  • trunk/core/curves.h

    r709 r1505  
    55 
    66 
     7// Defines of exported to chdk symbols 
     8#ifdef THIS_IS_CHDK_CORE 
     9        // This section is for CHDK core 
     10        extern void (*curve_set_mode)(); 
     11        extern void (*curve_init_mode)(); 
     12        extern void (*curve_apply)(); 
     13#else 
     14        // This section is for module 
     15        extern void curve_set_mode(); 
     16        extern void curve_init_mode(); 
     17        extern void curve_apply(); 
     18#endif 
     19 
    720//------------------------------------------------------------------- 
    8 extern void curve_set_mode(); 
    9 extern void curve_init_mode(); 
    10 extern void curve_apply(); 
    1121//------------------------------------------------------------------- 
    1222 
  • trunk/core/edgeoverlay.c

    r1499 r1505  
    11#include "platform.h" 
    22 
    3 #ifdef OPT_EDGEOVERLAY 
    43#include "edgeoverlay.h" 
    54#include "conf.h" 
     
    87#include "gui_draw.h" 
    98#include "bitvector.h" 
     9#include "module_exportlist.h" 
     10 
    1011 
    1112// the way we save edge overlays on their own... 
     
    1314#define EDGE_FILE_FORMAT EDGE_FILE_PREFIX "%04d.edg" 
    1415#define EDGE_SLICES     2 
     16 
     17int* conf_edge_overlay_filter; 
     18color* conf_osd_color; 
     19int* conf_edge_overlay_zoom; 
     20int* conf_edge_overlay_thresh; 
     21color* conf_edge_overlay_color; 
     22int* conf_edge_overlay_pano; 
     23int* conf_edge_overlay_pano_overlap; 
     24int* conf_edge_overlay_show; 
     25int* conf_edge_overlay_play; 
    1526 
    1627typedef enum _edge_fsm_state 
     
    5667            memset(edgebuf->ptr, 0, edgebuf->ptrLen); 
    5768    } 
    58     if (conf.edge_overlay_filter && (smbuf == NULL)) 
     69    if (*conf_edge_overlay_filter && (smbuf == NULL)) 
    5970    { 
    6071        smbuf = (unsigned char*)malloc(viewport_byte_width*3); 
     
    6475        { 
    6576            // Disable filtering if we do not have enough memory for it 
    66             conf.edge_overlay_filter = 0; 
     77            *conf_edge_overlay_filter = 0; 
    6778        } 
    6879    } 
     
    125136    char msg[64]; 
    126137    FILE *fd; 
    127     DIR* d; 
     138    STD_DIR* d; 
    128139    int fnum = 0; 
    129140    int fr = 0; 
    130141    int zoom = 0; 
    131     struct dirent* de; 
     142    struct STD_dirent* de; 
    132143    static struct utimbuf t; 
    133144    // nothing to save? then dont save 
     
    135146    if( !is_buffer_ready() ) 
    136147    { 
    137         draw_string(0, 0, "No overlay to save.", conf.osd_color); 
     148        draw_string(0, 0, "No overlay to save.", *conf_osd_color); 
    138149        return; 
    139150    } 
     
    142153 
    143154    // first figure out the most appropriate filename to use 
    144     d = opendir(EDGE_SAVE_DIR); 
     155    d = safe_opendir(EDGE_SAVE_DIR); 
    145156    if( ! d ) 
    146157    { 
     
    148159    } 
    149160 
    150     while( (de = readdir(d)) ) 
     161    while( (de = safe_readdir(d)) ) 
    151162    { 
    152163        fr = get_edge_file_num(de->d_name); 
     
    170181        utime(fn, &t); 
    171182        sprintf(msg, "Saved as %s",fn); 
    172         draw_string(0, 0, msg, conf.osd_color); 
    173     } 
    174     closedir(d); 
     183        draw_string(0, 0, msg, *conf_osd_color); 
     184    } 
     185    safe_closedir(d); 
    175186} 
    176187 
     
    192203        { 
    193204            fsm_state = EDGE_FROZEN;    // switch to "edge overlay frozen"-mode 
    194             if (conf.edge_overlay_zoom) 
     205            if (*conf_edge_overlay_zoom) 
    195206            { 
    196207                shooting_set_zoom(zoom); 
     
    300311    memset(edgebuf->ptr + slice*compressed_slice, 0, compressed_slice); 
    301312 
    302     if (conf.edge_overlay_filter) 
     313    if (*conf_edge_overlay_filter) 
    303314    { 
    304315        // Prefill smbuf with three lines of avergae-filtered data. 
     
    322333        shutter_fullpress |= kbd_is_key_pressed(KEY_SHOOT_FULL); 
    323334 
    324         if (conf.edge_overlay_filter) 
     335        if (*conf_edge_overlay_filter) 
    325336        { 
    326337            // We need to shift up our smbuf one line, 
     
    374385                conv2 = -conv2; 
    375386 
    376             if (conv1 + conv2 > conf.edge_overlay_thresh) 
     387            if (conv1 + conv2 > *conf_edge_overlay_thresh) 
    377388            { 
    378389                bv_set(edgebuf, (y-viewport_yoffset-EDGE_HMARGIN)*viewport_width + xdiv3, 1); 
     
    404415                conv2 = -conv2; 
    405416 
    406             if (conv1 + conv2 > conf.edge_overlay_thresh) 
     417            if (conv1 + conv2 > *conf_edge_overlay_thresh) 
    407418            { 
    408419                bv_set(edgebuf, (y-viewport_yoffset-EDGE_HMARGIN)*viewport_width + xdiv3+1, 1); 
     
    418429//  care so much about performance, you can enable it. 
    419430// 
    420 //    if (conf.edge_overlay_filter) 
     431//    if (*conf_edge_overlay_filter) 
    421432//    { 
    422433//        // Here we do basic filtering on the detected edges. 
     
    453464//                            bv_get(edgebuf, (y+1)*viewport_width + (x+1)); 
    454465// 
    455 //                        if (!conf.edge_overlay_show) 
     466//                        if (!*conf_edge_overlay_show) 
    456467//                        { 
    457468//                            if (sum >= 5)    // if we have at least 5 neighboring edges 
     
    481492    int x_off, y_off; 
    482493 
    483     const color cl = conf.edge_overlay_color; 
     494    const color cl = *conf_edge_overlay_color; 
    484495    const int y_slice_min = viewport_yoffset+EDGE_HMARGIN+ slice   *slice_height; 
    485496    const int y_slice_max = viewport_yoffset+EDGE_HMARGIN+(slice+1)*slice_height; 
     
    512523                    const int aspect_correct_x_off = x_off; 
    513524                    const int bEdge = bv_get(edgebuf, y_edgebuf + x); 
    514                     const int bDraw = bEdge || (draw_get_pixel(aspect_correct_x_off, y_off) == conf.edge_overlay_color); 
    515                     const color cl = bEdge ? conf.edge_overlay_color : 0; 
     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; 
    516527                    if (bEdge || bDraw) 
    517528                        draw_pixel(aspect_correct_x_off, y_off, cl); 
     
    571582    const int x_max = (viewport_width - 2); 
    572583 
    573     switch(conf.edge_overlay_pano) 
     584    switch(*conf_edge_overlay_pano) 
    574585    { 
    575586    case 0:     // pano off 
     
    578589        break; 
    579590    case 1:     // pano from left to right 
    580         xoffset = -x_max*(100-conf.edge_overlay_pano_overlap)/100; 
     591        xoffset = -x_max*(100-*conf_edge_overlay_pano_overlap)/100; 
    581592        break; 
    582593    case 2:     // pano from top to bottom 
    583         yoffset = -y_max*(100-conf.edge_overlay_pano_overlap)/100; 
     594        yoffset = -y_max*(100-*conf_edge_overlay_pano_overlap)/100; 
    584595        break; 
    585596    case 3:     // pano from right to left 
    586         xoffset = x_max*(100-conf.edge_overlay_pano_overlap)/100; 
     597        xoffset = x_max*(100-*conf_edge_overlay_pano_overlap)/100; 
    587598        break; 
    588599    case 4:     // pano from bottom to top 
    589         yoffset = y_max*(100-conf.edge_overlay_pano_overlap)/100; 
     600        yoffset = y_max*(100-*conf_edge_overlay_pano_overlap)/100; 
    590601        break; 
    591602    case 5:     // free mode 
     
    596607    } 
    597608} 
     609 
    598610 
    599611 
     
    607619void edge_overlay() 
    608620{ 
    609  
    610621    // Was the shutter fully pressed the last time we ran? 
    611622    // We use this to make sure that the user has released 
     
    625636    const int bHalfPress = kbd_is_key_pressed(KEY_SHOOT_HALF); 
    626637    const int bPlayMode = (mode_get() & MODE_MASK) == MODE_PLAY; 
    627     const int bPanoramaMode = (conf.edge_overlay_pano != 0); 
    628     const int bNeedHalfPress = (conf.edge_overlay_show != 1); 
    629     const int bDisplayInPlay = (conf.edge_overlay_play == 1); 
     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); 
    630641    const int bGuiModeNone = (gui_get_mode() == GUI_MODE_NONE); 
    631642    const int bGuiModeAlt = (gui_get_mode() == GUI_MODE_ALT); 
     
    710721            // calculations. 
    711722            bFullPress |= draw_edge_overlay(); 
    712             draw_string(0, 0, "Frozen", conf.osd_color); 
     723            draw_string(0, 0, "Frozen", *conf_osd_color); 
    713724        } 
    714725 
     
    743754}   // function 
    744755 
    745 #endif 
    746  
     756 
     757 
     758 
     759 
     760// =========  MODULE INIT ================= 
     761 
     762#include "module_load.h" 
     763int module_idx=-1; 
     764 
     765/***************** BEGIN OF AUXILARY PART ********************* 
     766  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     767 **************************************************************/ 
     768 
     769void* MODULE_EXPORT_LIST[] = { 
     770        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     771        /* 1 */ (void*)5, 
     772 
     773                        edge_overlay, 
     774                        save_edge_overlay, 
     775                        load_edge_overlay 
     776                }; 
     777 
     778 
     779//--------------------------------------------------------- 
     780// PURPOSE:   Bind module symbols with chdk.  
     781//              Required function 
     782// PARAMETERS: pointer to chdk list of export 
     783// RETURN VALUE: 1 error, 0 ok 
     784//--------------------------------------------------------- 
     785int _module_loader( void** chdk_export_list ) 
     786{ 
     787  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     788     return 1; 
     789 
     790  tConfigVal configVal; 
     791  CONF_BIND_INT(188, conf_edge_overlay_thresh); 
     792  CONF_BIND_COLOR(189, conf_edge_overlay_color); 
     793  CONF_BIND_INT(222, conf_edge_overlay_play); 
     794  CONF_BIND_INT(223, conf_edge_overlay_pano); 
     795  CONF_BIND_INT(224, conf_edge_overlay_zoom); 
     796  CONF_BIND_INT(241, conf_edge_overlay_filter); 
     797  CONF_BIND_INT(242, conf_edge_overlay_show); 
     798  CONF_BIND_INT(243, conf_edge_overlay_pano_overlap); 
     799  CONF_BIND_COLOR( 28, conf_osd_color); 
     800 
     801  return 0; 
     802} 
     803 
     804 
     805 
     806//--------------------------------------------------------- 
     807// PURPOSE: Finalize module operations (close allocs, etc) 
     808// RETURN VALUE: 0-ok, 1-fail 
     809//--------------------------------------------------------- 
     810int _module_unloader() 
     811{ 
     812        // This could be happens only if on-load mistake 
     813        // CHDK never unload this library (but load only if needed) 
     814        // Reason: edve_overlay allocate different bufs which should be kept 
     815        //              because even if we turn off edgeovr we could turn on back and 
     816        //              should get same content. 
     817  return 0; 
     818} 
     819 
     820/******************** Module Information structure ******************/ 
     821 
     822struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     823                                                                        sizeof(struct ModuleInfo), 
     824 
     825                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     826                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     827                                                                        MODULEINFO_FLAG_SYSTEM,         // flag 
     828                                                                        (int32_t)"Edge Overalay (dll)",// Module name 
     829                                                                        1, 0,                                           // Module version 
     830                                                                        (int32_t)"Implementation one of core modes" 
     831                                                                 }; 
     832 
     833 
     834/*************** END OF AUXILARY PART *******************/ 
     835 
  • trunk/core/edgeoverlay.h

    r928 r1505  
    99#define EDGE_SAVE_DIR "A/CHDK/EDGE" 
    1010 
     11// Defines of exported to chdk symbols 
     12#ifdef THIS_IS_CHDK_CORE 
     13        // This section is for CHDK core 
     14        extern void (*edge_overlay)(); 
     15        extern void (*save_edge_overlay)(void); 
     16        extern void (*load_edge_overlay)( const char* ); 
     17#else 
     18        // This section is for module 
    1119void edge_overlay(); 
    1220void save_edge_overlay(void); 
    1321void load_edge_overlay( const char* ); 
     22#endif 
    1423 
    1524#endif 
  • trunk/core/gui.c

    r1497 r1505  
    1414#include "gui_mbox.h" 
    1515#include "gui_mpopup.h" 
    16 #ifdef OPT_GAME_REVERSI 
    17 #include "gui_reversi.h" 
    18 #endif 
    19 #ifdef OPT_GAME_SOKOBAN 
    20 #include "gui_sokoban.h" 
    21 #endif 
    22 #ifdef OPT_GAME_CONNECT4 
    23 #include "gui_4wins.h" 
    24 #endif 
    25 #ifdef OPT_GAME_MASTERMIND 
    26 #include "gui_mastermind.h" 
    27 #endif 
    2816#include "console.h" 
    2917#ifdef OPT_DEBUGGING 
    3018#include "gui_debug.h" 
    31 #include "gui_bench.h" 
    3219#endif 
    3320#include "gui_fselect.h" 
     
    3926        #include "gui_read.h" 
    4027#endif 
    41 #ifdef OPT_CALENDAR 
    42         #include "gui_calendar.h" 
    43 #endif 
    4428#include "gui_grid.h" 
    4529#include "histogram.h" 
     
    5135#endif 
    5236#ifdef OPT_EDGEOVERLAY 
    53         #include "edgeoverlay.h" 
     37        #include "modules.h" 
    5438#endif 
    5539#ifdef OPT_SCRIPTING 
     
    5741    int script_params_has_changed=0; 
    5842#endif 
     43#include "module_load.h" 
     44 
    5945//------------------------------------------------------------------- 
    6046 
     
    160146static void gui_show_build_info(int arg); 
    161147static void gui_show_memory_info(int arg); 
    162 static void gui_draw_palette(int arg); 
    163 static void gui_draw_reversi(int arg); 
    164 static void gui_draw_sokoban(int arg); 
    165 static void gui_draw_4wins(int arg); 
    166 static void gui_draw_mastermind(int arg); 
     148static void     gui_modules_menu_load(); 
     149 
    167150#ifdef OPT_DEBUGGING 
    168         static void gui_draw_debug(int arg); 
    169         static void gui_draw_bench(int arg); 
    170151    void gui_compare_props(int arg); 
    171152    static void gui_menuproc_break_card(int arg); 
     
    318299#endif 
    319300 
    320 static CMenuItem games_submenu_items[] = { 
    321 #ifdef OPT_GAME_REVERSI 
    322     MENU_ITEM(0x38,LANG_MENU_GAMES_REVERSI,           MENUITEM_PROC,  gui_draw_reversi, 0 ), 
    323 #endif 
    324 #ifdef OPT_GAME_SOKOBAN 
    325     MENU_ITEM(0x38,LANG_MENU_GAMES_SOKOBAN,           MENUITEM_PROC,  gui_draw_sokoban, 0 ), 
    326 #endif 
    327 #ifdef OPT_GAME_CONNECT4 
    328     MENU_ITEM(0x38,LANG_MENU_GAMES_CONNECT4,             MENUITEM_PROC,  gui_draw_4wins, 0 ), 
    329 #endif 
    330 #ifdef OPT_GAME_MASTERMIND 
    331     MENU_ITEM(0x38,LANG_MENU_GAMES_MASTERMIND,           MENUITEM_PROC,  gui_draw_mastermind, 0 ), 
    332 #endif 
    333     MENU_ITEM(0x51,LANG_MENU_BACK,                    MENUITEM_UP, 0, 0 ), 
    334     {0} 
    335 }; 
    336 static CMenu games_submenu = {0x38,LANG_MENU_GAMES_TITLE, NULL, games_submenu_items }; 
    337  
    338301static const char* gui_autoiso_shutter_modes[] = { "Auto", "1/8s", "1/15s", "1/30s", "1/60s", "1/125s", "1/250s", "1/500s", "1/1000s"}; 
    339302static CMenuItem autoiso_submenu_items[] = { 
     
    377340    MENU_ITEM(0x2a,LANG_MENU_DEBUG_TASKLIST_START,    MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,   &debug_tasklist_start, MENU_MINMAX(0, 63) ), 
    378341    MENU_ITEM(0x5c,LANG_MENU_DEBUG_SHOW_MISC_VALS,    MENUITEM_BOOL,          &conf.debug_misc_vals_show, 0 ), 
    379     MENU_ITEM(0x2a,LANG_MENU_DEBUG_MEMORY_BROWSER,    MENUITEM_PROC,          gui_draw_debug, 0 ), 
    380     MENU_ITEM(0x2a,LANG_MENU_DEBUG_BENCHMARK,         MENUITEM_PROC,          gui_draw_bench, 0 ), 
    381342    MENU_ENUM2(0x5c,LANG_MENU_DEBUG_SHORTCUT_ACTION,  &conf.debug_shortcut_action, gui_debug_shortcut_modes ), 
    382343    MENU_ITEM(0x5c,LANG_MENU_RAW_TIMER,               MENUITEM_BOOL,          &conf.raw_timer, 0 ), 
     
    397358static CMenuItem misc_submenu_items[] = { 
    398359    MENU_ITEM(0x35,LANG_MENU_MISC_FILE_BROWSER,       MENUITEM_PROC,    gui_draw_fselect, 0 ), 
    399 #ifdef OPT_CALENDAR 
    400     MENU_ITEM(0x36,LANG_MENU_MISC_CALENDAR,           MENUITEM_PROC,    gui_draw_calendar, 0 ), 
    401 #endif 
     360    MENU_ITEM(0x65,(int)"Modules",                        MENUITEM_TEXT,    0, 0 ), 
    402361#ifdef OPT_TEXTREADER 
    403362    MENU_ITEM(0x37,LANG_MENU_MISC_TEXT_READER,        MENUITEM_SUBMENU, &reader_submenu, 0 ), 
    404 #endif 
    405 #if defined (OPT_GAME_REVERSI) || (OPT_GAME_SOKOBAN || (OPT_GAME_CONNECT4) || OPT_GAME_MASTERMIND) 
    406     MENU_ITEM(0x38,LANG_MENU_MISC_GAMES,              MENUITEM_SUBMENU, &games_submenu, 0 ), 
    407363#endif 
    408364#if CAM_SWIVEL_SCREEN 
     
    418374#endif 
    419375    MENU_ITEM(0x5d,LANG_MENU_MISC_DISABLE_LCD_OFF,    MENUITEM_ENUM,    gui_alt_power_enum, 0 ), 
    420     MENU_ITEM(0x65,LANG_MENU_MISC_PALETTE,            MENUITEM_PROC,    gui_draw_palette, 0 ), 
    421376    MENU_ITEM(0x80,LANG_MENU_MISC_BUILD_INFO,         MENUITEM_PROC,    gui_show_build_info, 0 ), 
    422377    MENU_ITEM(0x80,LANG_MENU_MISC_MEMORY_INFO,        MENUITEM_PROC,    gui_show_memory_info, 0 ), 
     
    10851040    gui_enum_value_change(&conf.curve_enable,change,sizeof(modes)/sizeof(modes[0])); 
    10861041 
    1087         if(change) 
     1042        if(change && curve_init_mode) 
    10881043                curve_init_mode(); 
    10891044    return modes[conf.curve_enable]; 
     
    11381093 
    11391094void gui_load_script(int arg) { 
    1140     gui_fselect_init(LANG_STR_SELECT_SCRIPT_FILE, conf.script_file, "A/CHDK/SCRIPTS", gui_load_script_selected); 
     1095    module_fselect_init(LANG_STR_SELECT_SCRIPT_FILE, conf.script_file, "A/CHDK/SCRIPTS", gui_load_script_selected); 
    11411096} 
    11421097 
     
    15171472void gui_raw_develop(int arg){ 
    15181473 int m=mode_get(); 
    1519  gui_fselect_init(LANG_RAW_DEVELOP_SELECT_FILE, "A/DCIM", "A", raw_fselect_cb); 
     1474 module_fselect_init(LANG_RAW_DEVELOP_SELECT_FILE, "A/DCIM", "A", raw_fselect_cb); 
    15201475} 
    15211476 
     
    16301585 
    16311586//------------------------------------------------------------------- 
    1632 static volatile enum Gui_Mode gui_mode; 
     1587static volatile gui_mode_t gui_mode;    // current gui mode. if <GUI_MODE_LASTIDX - idx in guiHandlers (core modes), otherwise pointer to gui_handler object (module modes) 
     1588 
    16331589static volatile int gui_restore; 
    16341590static volatile int gui_in_redraw; 
     
    16381594static Conf old_conf; 
    16391595#endif 
     1596 
     1597extern gui_handler guiHandlers[]; 
    16401598 
    16411599//------------------------------------------------------------------- 
     
    16501608    } 
    16511609    gui_splash = (conf.splash_show)?SPLASH_TIME:0; 
     1610 
     1611        gui_modules_menu_load(); 
    16521612    user_menu_restore(); 
    16531613    gui_lang_init(); 
     
    16601620#ifdef OPT_CURVES 
    16611621        // initialize curves, loading files if required by current mode 
    1662         curve_init_mode(); 
     1622        //curve_init_mode();    // @tsv it will be initialize on first load 
    16631623#endif 
    16641624#if ZOOM_OVERRIDE 
     
    16661626//              if (conf.zoom_override) shooting_set_zoom(conf.zoom_override_value); 
    16671627#endif 
     1628} 
     1629 
     1630 
     1631//------------------------------------------------------------------- 
     1632void gui_modules_menu_load(int arg){ 
     1633 
     1634        misc_submenu_items[1].type=MENUITEM_TEXT; 
     1635 
     1636        unsigned int argv[] ={  (unsigned int)MODULES_PATH, 
     1637                                                        (unsigned int)(&misc_submenu_items[1]) 
     1638                                                 }; 
     1639        module_run("modmenu.flt", 0, 2,argv, UNLOAD_IF_ERR ); 
    16681640} 
    16691641 
     
    16741646                // TODO we could sanity check here, but curve_set_type should fail gracefullish 
    16751647                strcpy(conf.curve_file,fn); 
    1676                 if(conf.curve_enable == 1) 
     1648                if(conf.curve_enable == 1 && curve_init_mode) 
    16771649                        curve_init_mode(); 
    16781650        } 
     
    16811653//------------------------------------------------------------------- 
    16821654void gui_load_curve(int arg) { 
    1683     gui_fselect_init(LANG_STR_SELECT_CURVE_FILE, conf.curve_file, CURVE_DIR, gui_load_curve_selected); 
    1684 } 
    1685  
    1686 #endif 
    1687 //------------------------------------------------------------------- 
    1688 enum Gui_Mode gui_get_mode() { 
     1655    module_fselect_init(LANG_STR_SELECT_CURVE_FILE, conf.curve_file, CURVE_DIR, gui_load_curve_selected); 
     1656} 
     1657 
     1658#endif 
     1659 
     1660 
     1661// Small hack: use understandable name to reused data member 
     1662#define binded_gui_mode_ptr kbd_process 
     1663 
     1664//------------------------------------------------------------------- 
     1665gui_mode_t gui_get_mode() { 
     1666    if ( gui_mode >= GUI_MODE_COUNT ) 
     1667        { 
     1668                int mode; 
     1669                for (mode=0;mode<GUI_MODE_COUNT;mode++) 
     1670                { 
     1671                        if ( (guiHandlers[mode].flags & GUI_MODE_FLAG_ALIAS) &&  
     1672                                        guiHandlers[mode].binded_gui_mode_ptr == (void*)gui_mode )  
     1673                                return mode; 
     1674                } 
     1675        } 
    16891676    return gui_mode; 
    16901677} 
    16911678 
    16921679//------------------------------------------------------------------- 
    1693 void gui_set_mode(enum Gui_Mode mode) { 
     1680void gui_set_mode(gui_mode_t mode)  
     1681{ 
     1682        if ( gui_mode == mode ) 
     1683                return; 
     1684 
     1685        if (  mode < GUI_MODE_COUNT &&  
     1686                  (guiHandlers[mode].flags & GUI_MODE_FLAG_ALIAS) )  
     1687        { 
     1688                mode = (unsigned int)guiHandlers[mode].binded_gui_mode_ptr;  
     1689        } 
     1690 
     1691        // Sanity check for case module pointer - is this really gui_handler 
     1692    if ( mode >= GUI_MODE_COUNT && ((gui_handler*)mode)->magicnum != GUI_MODE_MAGICNUM ) { 
     1693                // If sanity failed (module is unload) - set to default mode 
     1694        gui_mode = GUI_MODE_NONE; 
     1695                draw_restore(); 
     1696                return; 
     1697        } 
     1698         
    16941699#ifdef CAM_TOUCHSCREEN_UI 
    16951700    if (((gui_mode == 0) != (mode == 0)) ||                         // Change from GUI_MODE_NONE to any other or vice-versa 
     
    16991704    gui_mode = mode; 
    17001705} 
     1706 
     1707//------------------------------------------------------------------- 
     1708// PURPOSE: bind module struct to  
     1709// RETUN: 0 - fail, 1 - ok 
     1710int gui_bind_mode(int core_mode, gui_handler* handler) { 
     1711 
     1712        // sanity checks 
     1713    if ( core_mode >= GUI_MODE_COUNT || 
     1714                (guiHandlers[core_mode].flags & GUI_MODE_FLAG_ALIAS)==0 
     1715           ) 
     1716                return 0; 
     1717 
     1718        if ( handler && handler->magicnum != GUI_MODE_MAGICNUM ) 
     1719                return 0; 
     1720 
     1721        // check is this module is already binded (loaded with different name) 
     1722        gui_handler* bind_gui_handler = (gui_handler*)guiHandlers[core_mode].binded_gui_mode_ptr; 
     1723        if ( bind_gui_handler && bind_gui_handler->magicnum == GUI_MODE_MAGICNUM ) 
     1724                return 0; 
     1725 
     1726        guiHandlers[core_mode].binded_gui_mode_ptr = (void*)handler; 
     1727        return 1; 
     1728} 
     1729 
     1730#undef binded_gui_mode_ptr 
     1731 
    17011732 
    17021733//------------------------------------------------------------------- 
     
    19611992} 
    19621993 
    1963 // Menu button handled for text reader 
    1964 #ifdef OPT_TEXTREADER 
    1965 void gui_read_kbd_process_menu_btn() 
    1966 { 
    1967     gui_read_kbd_process(); 
    1968     gui_default_kbd_process_menu_btn(); 
    1969 } 
    1970 #endif 
    1971  
    19721994// Menu button handled for Menu mode 
    19731995void gui_menu_kbd_process_menu_btn() 
     
    19882010 
    19892011//------------------------------------------------------------------- 
    1990 // Structure to store gui redraw and kbd process handlers for each mode 
    1991 typedef struct 
     2012// GUI handler table (entries must be in the same order and have the same number of entries as Gui_Mode enum) 
     2013gui_handler guiHandlers[GUI_MODE_COUNT] = 
    19922014{ 
    1993     void (*redraw)(void);                   // Called to redraw screen 
    1994     void (*kbd_process)(void);              // Main button handler for mode 
    1995     void (*kbd_process_menu_btn)(void);     // Menu button handler for mode 
    1996 } gui_handler; 
    1997  
    1998 // GUI handler table (entries must be in the same order and have the same number of entries as Gui_Mode enum) 
    1999 gui_handler guiHandlers[] = 
    2000 { 
    2001     /*GUI_MODE_NONE*/           { gui_draw_osd,         0,                          0 }, 
    2002     /*GUI_MODE_ALT*/            { gui_chdk_draw,        gui_chdk_kbd_process,       gui_chdk_kbd_process_menu_btn }, 
    2003     /*GUI_MODE_MENU*/           { gui_menu_draw,        gui_menu_kbd_process,       gui_menu_kbd_process_menu_btn }, 
    2004     /*GUI_MODE_PALETTE*/        { gui_palette_draw,     gui_palette_kbd_process,    gui_default_kbd_process_menu_btn }, 
    2005     /*GUI_MODE_MBOX*/           { gui_mbox_draw,        gui_mbox_kbd_process,       0 }, 
    2006 #ifdef OPT_GAME_REVERSI 
    2007     /*GUI_MODE_REVERSI*/        { gui_reversi_draw,     gui_reversi_kbd_process,    gui_default_kbd_process_menu_btn }, 
    2008 #else 
    2009                                 { 0, 0, 0 }, 
    2010 #endif 
    2011 #ifdef OPT_GAME_SOKOBAN 
    2012     /*GUI_MODE_SOKOBAN*/        { gui_sokoban_draw,     gui_sokoban_kbd_process,    gui_default_kbd_process_menu_btn }, 
    2013 #else 
    2014                                 { 0, 0, 0 }, 
    2015 #endif 
    2016 #ifdef OPT_DEBUGGING 
    2017     /*GUI_MODE_DEBUG*/          { gui_debug_draw,       gui_debug_kbd_process,      gui_default_kbd_process_menu_btn }, 
    2018 #else 
    2019                                 { 0, 0, 0 }, 
    2020 #endif 
    2021     /*GUI_MODE_FSELECT*/        { gui_fselect_draw,     gui_fselect_kbd_process,    gui_fselect_kbd_process }, 
    2022 #ifdef OPT_TEXTREADER 
    2023     /*GUI_MODE_READ*/           { gui_read_draw,        gui_read_kbd_process,       gui_read_kbd_process_menu_btn }, 
    2024 #else 
    2025                                 { 0, 0, 0 }, 
    2026 #endif 
    2027     /*GUI_MODE_OSD*/            { gui_osd_draw,         gui_osd_kbd_process,        gui_default_kbd_process_menu_btn }, 
    2028 #ifdef OPT_CALENDAR 
    2029     /*GUI_MODE_CALENDAR*/       { gui_calendar_draw,    gui_calendar_kbd_process,   gui_default_kbd_process_menu_btn }, 
    2030 #else 
    2031                                 { 0, 0, 0 }, 
    2032 #endif 
    2033 #ifdef OPT_DEBUGGING 
    2034     /*GUI_MODE_BENCH*/          { gui_bench_draw,       gui_bench_kbd_process,      gui_default_kbd_process_menu_btn }, 
    2035 #else 
    2036                                 { 0, 0, 0 }, 
    2037 #endif 
    2038     /*GUI_MODE_MPOPUP*/         { gui_mpopup_draw,      gui_mpopup_kbd_process,     gui_mpopup_kbd_process }, 
    2039 #ifdef OPT_GAME_CONNECT4 
    2040     /*GUI_MODE_4WINS*/          { gui_4wins_draw,       gui_4wins_kbd_process,      gui_default_kbd_process_menu_btn }, 
    2041 #else 
    2042                                 { 0, 0, 0 }, 
    2043 #endif 
    2044 #ifdef OPT_GAME_MASTERMIND 
    2045     /*GUI_MODE_MASTERMIND*/     { gui_mastermind_draw,  gui_mastermind_kbd_process, gui_default_kbd_process_menu_btn }, 
    2046 #else 
    2047                                 { 0, 0, 0 }, 
    2048 #endif 
     2015    /*GUI_MODE_NONE*/           { gui_draw_osd,         0,                          0,                                                          0,                                                                      GUI_MODE_MAGICNUM }, 
     2016    /*GUI_MODE_ALT*/            { gui_chdk_draw,        gui_chdk_kbd_process,       gui_chdk_kbd_process_menu_btn,      0,                                                                      GUI_MODE_MAGICNUM },             
     2017    /*GUI_MODE_MENU*/           { gui_menu_draw,        gui_menu_kbd_process,       gui_menu_kbd_process_menu_btn,      0,                                                                      GUI_MODE_MAGICNUM }, 
     2018    /*GUI_MODE_ALIAS_PALETTE*/  { 0,                                    0,                                              0,                                                              GUI_MODE_FLAG_ALIAS,                            GUI_MODE_MAGICNUM }, 
     2019    /*GUI_MODE_MBOX*/           { gui_mbox_draw,        gui_mbox_kbd_process,       0,                                                          GUI_MODE_FLAG_NORESTORE_ON_SWITCH,      GUI_MODE_MAGICNUM }, 
     2020    /*GUI_MODE_ALIAS_FSELECT*/  { 0,                                    0,                                              0,                                                              GUI_MODE_FLAG_ALIAS,                            GUI_MODE_MAGICNUM }, 
     2021    /*GUI_MODE_OSD*/            { gui_osd_draw,         gui_osd_kbd_process,        gui_default_kbd_process_menu_btn, 0,                                                                 GUI_MODE_MAGICNUM },           // THIS IS OSD LAYOUT EDITOR 
     2022    /*GUI_MODE_ALIAS_MPOPUP*/   { 0,                                    0,                                              0,                                                              GUI_MODE_FLAG_ALIAS,                            GUI_MODE_MAGICNUM }, 
    20492023}; 
     2024 
    20502025 
    20512026//------------------------------------------------------------------- 
     
    20532028void gui_redraw() 
    20542029{ 
    2055     enum Gui_Mode gui_mode_old; 
     2030    static gui_mode_t gui_mode_prev_tick = GUI_MODE_NONE; 
     2031    gui_mode_t gui_mode_old; 
     2032 
     2033    static int flag_gui_enforce_redraw = 0; 
    20562034 
    20572035#ifdef CAM_DETECT_SCREEN_ERASE 
     
    20592037    { 
    20602038        draw_set_guard(); 
    2061         gui_menu_force_redraw(); 
    2062         gui_fselect_force_redraw(); 
     2039 
     2040                flag_gui_enforce_redraw |= GUI_REDRAWFLAG_ERASEGUARD; 
     2041        //gui_menu_force_redraw(); 
     2042        //gui_fselect_force_redraw();   //@tsv 
    20632043#ifdef CAM_TOUCHSCREEN_UI 
    20642044        extern int redraw_buttons; 
     
    20792059 
    20802060    // Call redraw handler 
    2081     if (guiHandlers[gui_mode].redraw) guiHandlers[gui_mode].redraw(); 
     2061        gui_handler* cur_gui_handler = (gui_mode<GUI_MODE_COUNT)? (&guiHandlers[gui_mode]) : (gui_handler*)gui_mode; 
     2062    if (cur_gui_handler->redraw) cur_gui_handler->redraw(flag_gui_enforce_redraw); 
     2063        flag_gui_enforce_redraw=0; 
    20822064 
    20832065    // Forced redraw if needed 
    20842066    gui_in_redraw = 0; 
    2085     if ((gui_mode_old != gui_mode && (gui_mode_old != GUI_MODE_NONE && gui_mode_old != GUI_MODE_ALT) && (gui_mode != GUI_MODE_MBOX && gui_mode != GUI_MODE_MPOPUP)) || gui_restore) { 
    2086         if (gui_restore) gui_menu_force_redraw(); 
     2067        cur_gui_handler = (gui_mode<GUI_MODE_COUNT)? (&guiHandlers[gui_mode]) : (gui_handler*)gui_mode; 
     2068    if ((gui_mode_old != gui_mode  
     2069                        && (gui_mode_old != GUI_MODE_NONE && gui_mode_old != GUI_MODE_ALT)  
     2070                        && !(cur_gui_handler->flags & GUI_MODE_FLAG_NORESTORE_ON_SWITCH))  
     2071            || gui_restore )  
     2072        { 
     2073 
     2074        if (gui_restore) 
     2075                        flag_gui_enforce_redraw |= GUI_REDRAWFLAG_DRAW_RESTORED; 
    20872076        gui_restore = 0; 
    2088         if (gui_mode != GUI_MODE_REVERSI && gui_mode != GUI_MODE_SOKOBAN && gui_mode != GUI_MODE_4WINS && gui_mode != GUI_MODE_MASTERMIND) 
     2077 
     2078        if ( !( cur_gui_handler->flags & GUI_MODE_FLAG_NODRAWRESTORE) ) 
    20892079            draw_restore(); 
    20902080    } 
     2081 
     2082        if ( gui_mode_prev_tick != gui_mode ) { 
     2083                flag_gui_enforce_redraw |= GUI_REDRAWFLAG_MODE_WAS_CHANGED; 
     2084                gui_mode_prev_tick = gui_mode; 
     2085        } 
    20912086} 
    20922087 
     
    20952090void gui_kbd_process() 
    20962091{ 
     2092        gui_handler* cur_gui_handler = (gui_mode<GUI_MODE_COUNT)? (&guiHandlers[gui_mode]) : (gui_handler*)gui_mode;     
     2093 
    20972094    // Call menu button handler if menu button pressed 
    20982095    if (kbd_is_key_clicked(KEY_MENU)) 
    20992096    { 
    2100         if (guiHandlers[gui_mode].kbd_process_menu_btn) guiHandlers[gui_mode].kbd_process_menu_btn(); 
     2097        if (cur_gui_handler->kbd_process_menu_btn) cur_gui_handler->kbd_process_menu_btn(); 
    21012098        return; 
    21022099    } 
    21032100 
    21042101    // Call mode handler for other buttons 
    2105     if (guiHandlers[gui_mode].kbd_process) guiHandlers[gui_mode].kbd_process(); 
     2102    if (cur_gui_handler->kbd_process) cur_gui_handler->kbd_process(); 
    21062103} 
    21072104 
     
    21432140#endif 
    21442141    draw_restore(); 
    2145     if (gui_mode == GUI_MODE_READ && !rbf_load(conf.menu_rbf_file)) 
    2146         rbf_load_from_8x16(current_font); 
    21472142    rbf_set_codepage(FONT_CP_WIN); 
    21482143    vid_turn_on_updates(); 
    21492144    gui_set_mode(GUI_MODE_NONE); 
     2145 
     2146        // Unload all modules which are marked as safe to unload 
     2147        module_async_unload_allrunned(0); 
    21502148 
    21512149        conf_update_prevent_shutdown(); 
     
    26072605 
    26082606//------------------------------------------------------------------- 
    2609 void gui_draw_palette(int arg) { 
    2610     draw_restore(); 
    2611     gui_palette_init(PALETTE_MODE_DEFAULT, 0x00, NULL); 
    2612     gui_set_mode(GUI_MODE_PALETTE); 
    2613 } 
    2614  
    2615 //------------------------------------------------------------------- 
    26162607void gui_show_build_info(int arg) { 
    26172608    static char buf[192]; 
     
    26392630 
    26402631//------------------------------------------------------------------- 
    2641 #ifdef OPT_GAME_REVERSI 
    2642 void gui_draw_reversi(int arg) { 
    2643     if ((mode_get()&MODE_MASK) != MODE_PLAY) { 
    2644         gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE, 
    2645                       MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL); 
    2646         return; 
    2647     } 
    2648  
    2649     gui_set_mode(GUI_MODE_REVERSI); 
    2650     gui_reversi_init(); 
    2651 } 
    2652 #endif 
    2653  
    2654 //------------------------------------------------------------------- 
    2655 #ifdef OPT_GAME_SOKOBAN 
    2656 void gui_draw_sokoban(int arg) { 
    2657     if ((mode_get()&MODE_MASK) != MODE_PLAY) { 
    2658         gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE, 
    2659                       MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL); 
    2660         return; 
    2661     } 
    2662     if ( gui_sokoban_init() ) 
    2663         gui_set_mode(GUI_MODE_SOKOBAN); 
    2664 } 
    2665 #endif 
    2666 //------------------------------------------------------------------- 
    2667 #ifdef OPT_GAME_CONNECT4 
    2668 void gui_draw_4wins(int arg) { 
    2669     if ((mode_get()&MODE_MASK) != MODE_PLAY) { 
    2670         gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE, 
    2671                       MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL); 
    2672         return; 
    2673     } 
    2674     if ( gui_4wins_init() ) 
    2675         gui_set_mode(GUI_MODE_4WINS); 
    2676 } 
    2677 #endif 
    2678 //------------------------------------------------------------------- 
    2679 #ifdef OPT_GAME_MASTERMIND 
    2680 void gui_draw_mastermind(int arg) { 
    2681     if ((mode_get()&MODE_MASK) != MODE_PLAY) { 
    2682         gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE, 
    2683                       MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL); 
    2684         return; 
    2685     } 
    2686     if ( gui_mastermind_init() ) 
    2687         gui_set_mode(GUI_MODE_MASTERMIND); 
    2688 } 
    2689 #endif 
    2690 //------------------------------------------------------------------- 
    2691 #ifdef OPT_DEBUGGING 
    2692 void gui_draw_debug(int arg) { 
    2693 //    gui_debug_init(0x2510); 
    2694 //    gui_debug_init(0x127E0); 
    2695 //    gui_debug_init(0x7F5B8); 
    2696 //    gui_debug_init(malloc(16)); 
    2697     gui_debug_init((void*)conf.mem_view_addr_init); 
    2698 } 
    2699  
    2700 //------------------------------------------------------------------- 
    2701 void gui_draw_bench(int arg) { 
    2702     gui_set_mode(GUI_MODE_BENCH); 
    2703     gui_bench_init(); 
    2704 } 
    2705 #endif 
    2706 //------------------------------------------------------------------- 
    2707  
     2632void gui_menu_run_fltmodule(int arg) { 
     2633    module_run((char*)arg, 0, 0,0, UNLOAD_IF_ERR); 
     2634} 
     2635 
     2636//------------------------------------------------------------------- 
    27082637void gui_draw_splash(char* logo, int logo_size) { 
    27092638    coord w, h, x, y; 
     
    27642693//------------------------------------------------------------------- 
    27652694void gui_draw_fselect(int arg) { 
    2766     gui_fselect_init(LANG_STR_FILE_BROWSER, "A", "A", NULL); 
     2695    module_fselect_init(LANG_STR_FILE_BROWSER, "A", "A", NULL); 
    27672696} 
    27682697 
     
    27732702} 
    27742703void gui_grid_lines_load(int arg) { 
    2775     gui_fselect_init(LANG_STR_SELECT_GRID_FILE, conf.grid_lines_file, "A/CHDK/GRIDS", gui_grid_lines_load_selected); 
     2704    module_fselect_init(LANG_STR_SELECT_GRID_FILE, conf.grid_lines_file, "A/CHDK/GRIDS", gui_grid_lines_load_selected); 
    27762705} 
    27772706 
     
    27892718            rbf_load_from_8x16(current_font); 
    27902719        rbf_set_codepage(conf.reader_codepage); 
    2791         gui_set_mode(GUI_MODE_READ); 
    2792         gui_read_init(fn); 
     2720 
     2721                unsigned int argv[] ={ (unsigned int)fn }; 
     2722                module_run("txtread.flt", 0, sizeof(argv)/sizeof(argv[0]), argv, UNLOAD_IF_ERR); 
    27932723    } 
    27942724} 
    27952725 
    27962726void gui_draw_read(int arg) { 
    2797     gui_fselect_init(LANG_STR_SELECT_TEXT_FILE, conf.reader_file, "A/CHDK/BOOKS", gui_draw_read_selected); 
     2727    module_fselect_init_w_mode(LANG_STR_SELECT_TEXT_FILE, conf.reader_file, "A/CHDK/BOOKS", gui_draw_read_selected, 1); 
    27982728    void gui_fselect_set_key_redraw(int n); 
    2799     gui_fselect_set_key_redraw(1); 
     2729    //gui_fselect_set_key_redraw(1);    @tsv 
    28002730} 
    28012731 
     
    28182748#ifdef OPT_EDGEOVERLAY 
    28192749static void gui_load_edge_selected( const char* fn ) { 
    2820     if( fn ) 
    2821         load_edge_overlay(fn); 
     2750    if( fn && module_edgeovr_load()) 
     2751                load_edge_overlay(fn); 
    28222752} 
    28232753 
    28242754void gui_menuproc_edge_save(int arg) { 
    2825     save_edge_overlay(); 
     2755        if ( module_edgeovr_load() ) 
     2756        save_edge_overlay(); 
    28262757} 
    28272758 
    28282759void gui_menuproc_edge_load(int arg) { 
    2829     gui_fselect_init(LANG_MENU_EDGE_LOAD, EDGE_SAVE_DIR, EDGE_SAVE_DIR, gui_load_edge_selected); 
    2830 } 
    2831 #endif 
    2832  
    2833 //------------------------------------------------------------------- 
    2834 #ifdef OPT_CALENDAR 
    2835 void gui_draw_calendar(int arg) { 
    2836     gui_set_mode(GUI_MODE_CALENDAR); 
    2837     gui_calendar_init(); 
    2838 } 
    2839 #endif 
     2760    module_fselect_init(LANG_MENU_EDGE_LOAD, EDGE_SAVE_DIR, EDGE_SAVE_DIR, gui_load_edge_selected); 
     2761} 
     2762#endif 
     2763 
    28402764//------------------------------------------------------------------- 
    28412765#ifdef OPT_TEXTREADER 
     
    28462770} 
    28472771void gui_draw_load_rbf(int arg) { 
    2848     gui_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.reader_rbf_file, "A/CHDK/FONTS", gui_draw_rbf_selected); 
     2772    module_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.reader_rbf_file, "A/CHDK/FONTS", gui_draw_rbf_selected); 
    28492773} 
    28502774#endif 
     
    28602784} 
    28612785void gui_draw_load_menu_rbf(int arg) { 
    2862     gui_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.menu_rbf_file, "A/CHDK/FONTS", gui_draw_menu_rbf_selected); 
     2786    module_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.menu_rbf_file, "A/CHDK/FONTS", gui_draw_menu_rbf_selected); 
    28632787} 
    28642788 
     
    28722796} 
    28732797void gui_draw_load_symbol_rbf(int arg) { 
    2874     gui_fselect_init(LANG_STR_SELECT_SYMBOL_FILE, conf.menu_symbol_rbf_file, "A/CHDK/SYMBOLS", gui_draw_symbol_rbf_selected); 
     2798    module_fselect_init(LANG_STR_SELECT_SYMBOL_FILE, conf.menu_symbol_rbf_file, "A/CHDK/SYMBOLS", gui_draw_symbol_rbf_selected); 
    28752799} 
    28762800 
     
    28842808} 
    28852809void gui_draw_load_lang(int arg) { 
    2886     gui_fselect_init(LANG_STR_SELECT_LANG_FILE, conf.lang_file, "A/CHDK/LANG", gui_draw_lang_selected); 
    2887 } 
    2888  
    2889 int find_mnu(CMenu *curr_menu, int mnu, int count) 
     2810    module_fselect_init(LANG_STR_SELECT_LANG_FILE, conf.lang_file, "A/CHDK/LANG", gui_draw_lang_selected); 
     2811} 
     2812 
     2813CMenuItem* find_mnu(CMenu *curr_menu, int itemid ) 
    28902814{ 
    28912815        int gui_menu_curr_item; 
     2816        CMenuItem* rv=0; 
     2817 
     2818        if ( itemid==0 ) 
     2819                return 0;                
    28922820 
    28932821        gui_menu_curr_item = 0; 
    28942822        while(curr_menu->menu[gui_menu_curr_item].text) { 
    2895                 if (curr_menu->menu[gui_menu_curr_item].text == mnu){ 
    2896                         user_submenu_items[count] = curr_menu->menu[gui_menu_curr_item]; 
    2897                         return 1; 
     2823                if ( lang_strhash31(curr_menu->menu[gui_menu_curr_item].text) == itemid){ 
     2824                        return (CMenuItem*) &(curr_menu->menu[gui_menu_curr_item]); 
    28982825                } 
    28992826                if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK) == MENUITEM_SUBMENU) 
    2900                         if (curr_menu->menu[gui_menu_curr_item].text != LANG_MENU_USER_MENU) 
    2901                                 if (find_mnu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), mnu, count)) return 1; 
     2827                        if (curr_menu->menu[gui_menu_curr_item].text != LANG_MENU_USER_MENU) { 
     2828                                rv = find_mnu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), itemid); 
     2829                                if ( rv ) 
     2830                                        return rv; 
     2831                        } 
    29022832                gui_menu_curr_item++; 
    29032833        } 
     
    29122842                 * conf.user_menu_vars only traks/saves the real user entries. 
    29132843                 */ 
    2914                 conf.user_menu_vars[x] = user_submenu_items[x+1].text; 
     2844                conf.user_menu_vars[x] = lang_strhash31(user_submenu_items[x+1].text); 
    29152845        } 
    29162846} 
    29172847 
    29182848void user_menu_restore() { 
    2919      int x; 
     2849    int x; 
     2850        CMenuItem* item=0; 
     2851 
    29202852        for (x=0; x<USER_MENU_ITEMS; x++) { 
    29212853                /* 
     
    29232855                 * conf.user_menu_vars only traks/saves the real user entries. 
    29242856                 */ 
    2925                 find_mnu(&root_menu, conf.user_menu_vars[x], x+1); 
     2857                 item = find_mnu(&root_menu, conf.user_menu_vars[x]); 
     2858                 if ( item ) 
     2859                        user_submenu_items[x+1] = *item; 
    29262860        } 
    29272861} 
  • trunk/core/gui_4wins.c

    r1338 r1505  
    1313#include "gui_mbox.h" 
    1414#include "gui_4wins.h" 
     15 
     16#include "module_load.h" 
     17void gui_module_menu_kbd_process(); 
     18 
     19gui_handler GUI_MODE_4WINS =  
     20    /*GUI_MODE_4WINS*/          { gui_4wins_draw,       gui_4wins_kbd_process,      gui_module_menu_kbd_process, GUI_MODE_FLAG_NODRAWRESTORE, GUI_MODE_MAGICNUM }; 
     21 
    1522 
    1623#define BORDER           20 
     
    243250                draw_txt_string(x, 4, lang_str(LANG_CONNECT4_HUMAN), TEXT_COLOR); 
    244251        else 
    245                 draw_txt_string(x, 4, PLATFORM, TEXT_COLOR); 
     252                draw_txt_string(x, 4, "cam", TEXT_COLOR); 
    246253} 
    247254//------------------------------------------------------------------- 
     
    331338        draw_mode(); 
    332339        if(cur_player==2&&!mode_rival) set(); 
     340 
     341    gui_set_mode((unsigned int)&GUI_MODE_4WINS); 
     342 
    333343        return 1; 
    334344} 
     345 
     346int basic_module_init() { 
     347  return gui_4wins_init(); 
     348} 
     349 
    335350//------------------------------------------------------------------- 
    336351void gui_4wins_kbd_process()  
     
    352367} 
    353368//------------------------------------------------------------------- 
    354 void gui_4wins_draw() { 
     369void gui_4wins_draw(int enforce_redraw) { 
    355370  static char str[16]; 
    356371  sprintf(str, "%3d%%", get_batt_perc()); 
     
    358373  gui_osd_draw_clock(CAM_TS_BUTTON_BORDER+290,208,INFO_TEXT_COLOR); 
    359374} 
     375 
     376extern int module_idx; 
     377void gui_module_menu_kbd_process() { 
     378        gui_default_kbd_process_menu_btn(); 
     379        module_async_unload(module_idx); 
     380} 
     381 
     382/******************** Module Information structure ******************/ 
     383 
     384struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     385                                                                        sizeof(struct ModuleInfo), 
     386 
     387                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     388                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     389                                                                        0,                                                      // flag 
     390                                                                        -LANG_MENU_GAMES_CONNECT4,      // Module name 
     391                                                                        1, 0,                                           // Module version 
     392                                                                        (int32_t) "Game" 
     393                                                                 }; 
  • trunk/core/gui_4wins.h

    r600 r1505  
    55extern int gui_4wins_init(); 
    66extern void gui_4wins_kbd_process(); 
    7 extern void gui_4wins_draw(); 
     7extern void gui_4wins_draw(int enforce_redraw); 
    88 
    99//------------------------------------------------------------------- 
  • trunk/core/gui_bench.c

    r1024 r1505  
    88#include "gui_draw.h" 
    99#include "gui_bench.h" 
     10 
     11#include "module_load.h" 
     12void gui_bench_draw_callback(int enforce_redraw); 
     13void gui_bench_menu_kbd_process(); 
     14 
     15gui_handler GUI_MODE_BENCH =  
     16    /*GUI_MODE_BENCH*/          { gui_bench_draw_callback,   gui_bench_kbd_process,      gui_bench_menu_kbd_process, 0, GUI_MODE_MAGICNUM }; 
     17 
    1018 
    1119//------------------------------------------------------------------- 
     
    99107    } 
    100108} 
     109 
     110void gui_bench_draw_callback(int enforce_redraw) { 
     111        gui_bench_draw(); 
     112} 
     113 
    101114 
    102115//------------------------------------------------------------------- 
     
    158171    } 
    159172 
    160     x = open("A/BENCH.TMP", O_WRONLY|O_CREAT, 0777); 
     173    x = safe_open("A/BENCH.TMP", O_WRONLY|STD_O_CREAT, 0777); 
    161174    if (x>=0) { 
    162175        bench.disk_write_raw_bps = 0; 
     
    170183    } 
    171184 
    172     x = open("A/BENCH.TMP", O_WRONLY|O_CREAT, 0777); 
     185    x = safe_open("A/BENCH.TMP", O_WRONLY|STD_O_CREAT, 0777); 
    173186    if (x>=0) { 
    174187        bench.disk_write_mem_bps = 0; 
     
    183196 
    184197    if (buf) { 
    185         x = open("A/BENCH.TMP", O_WRONLY|O_CREAT, 0777); 
     198        x = safe_open("A/BENCH.TMP", O_WRONLY|STD_O_CREAT, 0777); 
    186199        if (x>=0) { 
    187200            bench.disk_write_buf_bps = 0; 
     
    197210        } 
    198211 
    199         x = open("A/BENCH.TMP", O_RDONLY, 0777); 
     212        x = safe_open("A/BENCH.TMP", O_RDONLY, 0777); 
    200213        if (x>=0) { 
    201214            bench.disk_read_buf_bps = 0; 
     
    229242//------------------------------------------------------------------- 
    230243 
     244int basic_module_init() { 
     245        gui_bench_init(); 
     246    gui_set_mode( (unsigned int)&GUI_MODE_BENCH ); 
     247        return 1; 
     248} 
     249 
     250extern int module_idx; 
     251 
     252void gui_bench_menu_kbd_process() { 
     253        gui_default_kbd_process_menu_btn(); 
     254        module_async_unload(module_idx); 
     255} 
     256 
     257/******************** Module Information structure ******************/ 
     258 
     259struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     260                                                                        sizeof(struct ModuleInfo), 
     261 
     262                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     263                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     264                                                                        0,                                                      // flag 
     265                                                                        -LANG_MENU_DEBUG_BENCHMARK,     // Module name 
     266                                                                        1, 0,                                           // Module version 
     267                                                                        (int32_t) "Test camera low level perfomance" 
     268                                                                 }; 
  • trunk/core/gui_calendar.c

    r1338 r1505  
    1010#include "gui_calendar.h" 
    1111 
     12#include "module_load.h" 
     13void gui_calendar_menu_kbd_process(); 
     14 
     15gui_handler GUI_MODE_CALENDAR =  
     16    /*GUI_MODE_CALENDAR*/       { gui_calendar_draw,    gui_calendar_kbd_process,   gui_calendar_menu_kbd_process, 0, GUI_MODE_MAGICNUM }; 
     17 
    1218//------------------------------------------------------------------- 
    1319#define TITLE_COLOR             (MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)) 
     
    7581 
    7682//------------------------------------------------------------------- 
    77 void gui_calendar_init() { 
     83int basic_module_init() { 
     84 
     85    gui_set_mode( (unsigned int)&GUI_MODE_CALENDAR ); 
     86 
    7887    calendar_goto_today(); 
    7988    cal_w = FONT_WIDTH*4*7; 
     
    8392    gui_calendar_initial_draw(); 
    8493    need_redraw = 1; 
     94        return 1; 
    8595} 
    8696 
     
    110120            need_redraw = 1; 
    111121            break; 
    112       #if CAM_HAS_ERASE_BUTTON 
    113122        case KEY_ERASE: 
    114       #else 
    115123        case KEY_DISPLAY: 
    116       #endif 
    117124            calendar_goto_today(); 
    118125            need_redraw = 1; 
     
    122129 
    123130//------------------------------------------------------------------- 
    124 void gui_calendar_draw() { 
     131void gui_calendar_draw(int enforce_redraw) { 
    125132    int x, y; 
    126133    static char str[32]; 
     
    173180} 
    174181 
     182extern int module_idx; 
     183 
     184void gui_calendar_menu_kbd_process() { 
     185        gui_default_kbd_process_menu_btn(); 
     186        module_async_unload(module_idx); 
     187} 
     188 
     189/******************** Module Information structure ******************/ 
     190 
     191struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     192                                                                        sizeof(struct ModuleInfo), 
     193 
     194                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     195                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     196                                                                        0,                                                      // flag 
     197                                                                        -LANG_MENU_MISC_CALENDAR,       // Module name 
     198                                                                        1, 0,                                           // Module version 
     199                                                                        0 
     200                                                                 }; 
  • trunk/core/gui_calendar.h

    r515 r1505  
    55extern void gui_calendar_init(); 
    66extern void gui_calendar_kbd_process(); 
    7 extern void gui_calendar_draw(); 
     7extern void gui_calendar_draw(int enforce_redraw); 
    88 
    99//------------------------------------------------------------------- 
  • trunk/core/gui_debug.c

    r1024 r1505  
    88#include "conf.h" 
    99 
     10#include "module_load.h" 
     11 
     12extern void gui_module_menu_kbd_process(); 
     13int *conf_mem_view_addr_init; 
     14 
     15gui_handler GUI_MODE_DEBUG =  
     16    /*GUI_MODE_DEBUG*/          { gui_debug_draw,       gui_debug_kbd_process,      gui_module_menu_kbd_process, 0, GUI_MODE_MAGICNUM }; 
    1017 
    1118//------------------------------------------------------------------- 
     
    2330    debug_cont_update = 1; 
    2431    step = 4; 
    25     gui_set_mode(GUI_MODE_DEBUG); 
     32    gui_set_mode((unsigned int)&GUI_MODE_DEBUG); 
    2633} 
    2734 
     
    3037    int i; 
    3138 
    32     if (!(addr<=(void*)MAXRAMADDR || addr>=(void*)ROMBASEADDR)) { addr = &dummy; }; 
     39        // non-significant check. remove to platform independency 
     40    // if (!(addr<=(void*)MAXRAMADDR || addr>=(void*)ROMBASEADDR)) { addr = &dummy; }; 
    3341 
    3442    sprintf(buf, "0x%08X (%10u)", *((unsigned int*)addr), *((unsigned int*)addr)); 
     
    5664 
    5765//------------------------------------------------------------------- 
    58 void gui_debug_draw() { 
     66void gui_debug_draw(int enforce_redraw) { 
    5967    switch (debug_to_draw) { 
    6068        case 1: 
     
    8795            gui_debug_draw_values(2, addr); 
    8896            gui_debug_draw_values(8, *((void**)addr)); 
    89             conf.mem_view_addr_init = (long)addr; 
     97            *conf_mem_view_addr_init = (long)addr; 
    9098 
    9199            if (debug_cont_update==0) debug_to_draw = 0; 
     
    142150 
    143151//------------------------------------------------------------------- 
     152 
     153extern int module_idx; 
     154void gui_module_menu_kbd_process() { 
     155        gui_default_kbd_process_menu_btn(); 
     156        module_async_unload(module_idx); 
     157} 
     158 
     159 
     160// =========  MODULE INIT ================= 
     161#include "module_load.h" 
     162int module_idx=-1; 
     163 
     164/***************** BEGIN OF AUXILARY PART ********************* 
     165  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     166 **************************************************************/ 
     167 
     168void* MODULE_EXPORT_LIST[] = { 
     169        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     170        /* 1 */ (void*)0 
     171                }; 
     172 
     173 
     174//--------------------------------------------------------- 
     175// PURPOSE:   Bind module symbols with chdk.  
     176//              Required function 
     177// PARAMETERS: pointer to chdk list of export 
     178// RETURN VALUE: 1 error, 0 ok 
     179//--------------------------------------------------------- 
     180int _module_loader( void** chdk_export_list ) 
     181{ 
     182  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     183     return 1; 
     184 
     185  tConfigVal configVal; 
     186  CONF_BIND_INT(195, conf_mem_view_addr_init); 
     187 
     188  return 0; 
     189} 
     190 
     191 
     192 
     193//--------------------------------------------------------- 
     194// PURPOSE: Finalize module operations (close allocs, etc) 
     195// RETURN VALUE: 0-ok, 1-fail 
     196//--------------------------------------------------------- 
     197int _module_unloader() 
     198{ 
     199  return 0; 
     200} 
     201 
     202 
     203//--------------------------------------------------------- 
     204// PURPOSE: Default action for simple modules (direct run) 
     205// NOTE: Please comment this function if no default action and this library module 
     206//--------------------------------------------------------- 
     207int _module_run(int moduleidx, int argn, int* arguments) 
     208{ 
     209  module_idx=moduleidx; 
     210 
     211  void* adr; 
     212 
     213  if ( argn== 0 ) 
     214    adr =(char*)(*conf_mem_view_addr_init); 
     215  else if ( argn ==1) 
     216    adr = (char*)arguments[0];  
     217  else { 
     218        module_async_unload(moduleidx); 
     219    return 1; 
     220  } 
     221 
     222  gui_debug_init(adr); 
     223 
     224  return 0; 
     225} 
     226 
     227 
     228/******************** Module Information structure ******************/ 
     229#include "gui_lang.h" 
     230 
     231struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     232                                                                        sizeof(struct ModuleInfo), 
     233 
     234                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     235                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     236                                                                        0,                                                      // flag 
     237                                                                        -LANG_MENU_DEBUG_MEMORY_BROWSER,        // Module name 
     238                                                                        1, 0,                                           // Module version 
     239                                                                        (int32_t)"Simple memory content browser" 
     240                                                                 }; 
     241 
     242/*************** END OF AUXILARY PART *******************/ 
  • trunk/core/gui_debug.h

    r515 r1505  
    66extern void gui_debug_init(void* st_addr); 
    77extern void gui_debug_kbd_process(); 
    8 extern void gui_debug_draw(); 
     8extern void gui_debug_draw(int enforce_redraw); 
    99 
    1010//------------------------------------------------------------------- 
  • trunk/core/gui_draw.c

    r1365 r1505  
    303303} 
    304304 
     305// Restore CANON_OSD 
    305306//------------------------------------------------------------------- 
    306307void draw_restore() { 
  • trunk/core/gui_draw.h

    r1496 r1505  
    33 
    44#include        "camera.h"              // ensure the camera defintion is loaded 
     5 
     6#include "gui.h"        // for color, coord definitions 
     7 
     8 
     9// Common colors that are the same in all palettes 
     10#define COLOR_TRANSPARENT   0x00 
     11#define COLOR_BLACK         0xFF 
    512 
    613//------------------------------------------------------------------- 
     
    1118 
    1219//------------------------------------------------------------------- 
    13  
    14 // Common colors that are the same in all palettes 
    15 #define COLOR_TRANSPARENT   0x00 
    16 #define COLOR_BLACK         0xFF 
    1720 
    1821//------------------------------------------------------------------- 
  • trunk/core/gui_fselect.c

    r1423 r1505  
    1010#include "gui_mpopup.h" 
    1111#include "gui_fselect.h" 
    12 #include "raw_merge.h" 
     12#include "modules.h" 
    1313#include "raw.h" 
    1414#include "conf.h" 
    1515#include "dng.h" 
     16 
     17#include "module_load.h" 
     18 
     19gui_handler GUI_MODE_FSELECT_MODULE =  
     20    /*GUI_MODE_FSELECT*/        { gui_fselect_draw,     gui_fselect_kbd_process,    gui_fselect_kbd_process,            0,      GUI_MODE_MAGICNUM }; 
     21 
     22extern int module_idx; 
     23 
     24int *conf_sub_batch_prefix; 
     25int *conf_sub_batch_ext; 
     26 
     27struct librawop_sym* librawop_p; 
     28 
    1629 
    1730//------------------------------------------------------------------- 
     
    4760static char selected_file[100];     // This full path to current file. So it is return value 
    4861static char buf[100]; 
    49 static enum Gui_Mode    gui_fselect_mode_old; // stored previous gui_mode 
     62static gui_mode_t gui_fselect_mode_old; // stored previous gui_mode 
    5063 
    5164// basic element of file list 
     
    8295static int set_key_redraw_mode; // dirty hack: screen erase & mode restore done after(0) or before(1) call to fselect_on_select 
    8396 
     97// FSelector POPUP 
     98#define MPOPUP_CUT              0x0001 
     99#define MPOPUP_COPY             0x0002 
     100#define MPOPUP_PASTE            0x0004 
     101#define MPOPUP_DELETE           0x0008 
     102#define MPOPUP_SELINV           0x0010 
     103#define MPOPUP_RAW_ADD          0x0020 
     104#define MPOPUP_RAW_AVERAGE      0x0040 
     105#define MPOPUP_PURGE            0x0080 
     106#define MPOPUP_SUBTRACT         0x0100 
     107#define MPOPUP_RAW_DEVELOP      0x0200 
     108#define MPOPUP_DNG_TO_CRW       0x0400 
     109#define MPOPUP_EDITOR           0x0800 
     110#define MPOPUP_CHDK_REPLACE     0x1000 
     111 
     112static struct mpopup_item popup[]= { 
     113        { MPOPUP_CUT,           LANG_POPUP_CUT    }, 
     114        { MPOPUP_COPY,          LANG_POPUP_COPY   }, 
     115        { MPOPUP_PASTE,         LANG_POPUP_PASTE  }, 
     116        { MPOPUP_DELETE,        LANG_POPUP_DELETE }, 
     117        { MPOPUP_SELINV,        LANG_POPUP_SELINV }, 
     118        { MPOPUP_RAW_ADD,       LANG_POPUP_RAW_SUM}, 
     119        { MPOPUP_RAW_AVERAGE,   LANG_POPUP_RAW_AVERAGE }, 
     120        { MPOPUP_RAW_DEVELOP,   LANG_MENU_RAW_DEVELOP }, 
     121        { MPOPUP_PURGE,         LANG_POPUP_PURGE  }, 
     122        { MPOPUP_SUBTRACT,      LANG_POPUP_SUB_FROM_MARKED  }, 
     123        { MPOPUP_DNG_TO_CRW,    (int)"DNG -> CHDK RAW"}, 
     124        { MPOPUP_EDITOR,        (int)"Edit" }, 
     125        { MPOPUP_CHDK_REPLACE,  (int)"Set this CHDK" }, 
     126        { 0,                                    0 }, 
     127}; 
     128 
    84129//------------------------------------------------------------------- 
    85130static void fselect_goto_prev(int step) { 
     
    121166 
    122167//------------------------------------------------------------------- 
    123 // Called from other gui functions to force redraw of menu 
    124 void gui_fselect_force_redraw() 
    125 { 
    126     if (gui_get_mode() == GUI_MODE_FSELECT) 
    127     { 
    128         gui_fselect_redraw = 2; 
    129     } 
    130 } 
    131  
    132 //------------------------------------------------------------------- 
    133168static void gui_fselect_free_data() { 
    134169    struct fitem  *ptr = head, *prev; 
     
    173208//------------------------------------------------------------------- 
    174209static void gui_fselect_read_dir(const char* dir) { 
    175     DIR           *d; 
    176     struct dirent *de; 
    177     static struct stat   st; 
     210    STD_DIR           *d; 
     211    struct STD_dirent *de; 
     212    static struct STD_stat   st; 
    178213    struct fitem  **ptr = &head, *prev = NULL; 
    179214    int    i; 
    180215 
    181216    gui_fselect_free_data(); 
    182 #ifdef CAM_DRYOS_2_3_R39 
     217//#ifdef CAM_DRYOS_2_3_R39 
    183218    if(dir[0]=='A' && dir[1]==0) 
    184         d = opendir("A/"); 
     219        d = safe_opendir("A/"); 
    185220    else 
    186         d = opendir(dir); 
     221        d = safe_opendir(dir); 
     222/* //remove for platf independedncy. looks like sequence above is safe 
    187223#else 
    188     d = opendir(dir); 
     224    d = safe_opendir(dir); 
    189225#endif 
     226*/ 
    190227    if (d) { 
    191         de = readdir(d); 
     228        de = safe_readdir(d); 
    192229        while (de) { 
    193230            if (de->d_name[0] != 0xE5 /* deleted entry */ && (de->d_name[0]!='.' || de->d_name[1]!=0)) { 
     
    199236                        strcpy((*ptr)->name, de->d_name); 
    200237                    sprintf(buf, "%s/%s", dir, de->d_name); 
    201                     if (stat(buf, &st)==0) { 
     238                    if (safe_stat(buf, &st)==0) { 
    202239                        (*ptr)->attr=st.st_attrib; 
    203240                        (*ptr)->size=st.st_size; 
     
    214251                }    
    215252            } 
    216             de = readdir(d); 
    217         } 
    218         closedir(d); 
     253            de = safe_readdir(d); 
     254        } 
     255        safe_closedir(d); 
    219256    } 
    220257    *ptr=NULL; 
     
    273310    while (strlen(current_dir) > 0) 
    274311    { 
    275         struct stat st; 
     312        struct STD_stat st; 
    276313        // check if input 'dir' exists 
    277         if (stat(current_dir,&st) == 0)      
     314        if (safe_stat(current_dir,&st) == 0)      
    278315        { 
    279316            // exists - check if it is a directory or file 
     
    305342 
    306343//------------------------------------------------------------------- 
    307 void gui_fselect_init(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn)) { 
     344void gui_fselect_init(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn))  
     345{ 
    308346    int i; 
    309347     
     
    354392    gui_fselect_mode_old = gui_get_mode(); 
    355393    gui_fselect_redraw = 2; 
    356     gui_set_mode(GUI_MODE_FSELECT); 
     394    gui_set_mode((unsigned int)&GUI_MODE_FSELECT_MODULE); 
    357395    gui_fselect_set_key_redraw(0); 
    358396} 
     
    381419 
    382420//------------------------------------------------------------------- 
    383 void gui_fselect_draw() { 
     421void gui_fselect_draw(int enforce_redraw) { 
    384422    int i, j, off_name_x, off_size_x, off_time_x, off_body_x, off_body_y; 
    385423    struct fitem  *ptr; 
     
    389427    color cl_markered = ((mode_get()&MODE_MASK) == MODE_REC)?COLOR_YELLOW:0x66; 
    390428    color cl_marked, cl_selected; 
     429 
     430        if ( enforce_redraw ) 
     431                gui_fselect_redraw = 2; 
    391432 
    392433    if (gui_fselect_redraw) { 
     
    531572static void fselect_purge_cb(unsigned int btn) { 
    532573 
    533    DIR             *d,  *d2,  *d3,  *d4; 
    534    struct dirent   *de, *de2, *de3, *de4; 
     574   STD_DIR             *d,  *d2,  *d3,  *d4; 
     575   struct STD_dirent   *de, *de2, *de3, *de4; 
    535576   struct fitem    *ptr, *ptr2; 
    536577   char            sub_dir[20], sub_dir_search[20]; 
     
    542583       if (selected->name[0] == 'D' && selected->name[1] == 'C' && selected->name[2] == 'I' && selected->name[3] == 'M') { 
    543584           sprintf(current_dir+strlen(current_dir), "/%s", selected->name); 
    544            d=opendir(current_dir); 
    545            while ((de=readdir(d)) != NULL) {//Loop to find all Canon folders 
     585           d=safe_opendir(current_dir); 
     586           while ((de=safe_readdir(d)) != NULL) {//Loop to find all Canon folders 
    546587               if (de->d_name[0] != '.' && de->d_name[1] != '.') {//If item is not UpDir 
    547588                   sprintf(sub_dir, "%s/%s", current_dir, de->d_name); 
    548                    d2=opendir(sub_dir); 
    549                    while ((de2=readdir(d2)) != NULL) {//Loop to find all the RAW files inside a Canon folder 
     589                   d2=safe_opendir(sub_dir); 
     590                   while ((de2=safe_readdir(d2)) != NULL) {//Loop to find all the RAW files inside a Canon folder 
    550591                       if (de2->d_name[0] == 'C' || de2->d_name[9] == 'C') {//If file is RAW (Either CRW/CR2 prefix or file extension) 
    551                            d3=opendir(current_dir); 
    552                            while ((de3=readdir(d3)) != NULL) {//Loop to find all Canon folders 
     592                           d3=safe_opendir(current_dir); 
     593                           while ((de3=safe_readdir(d3)) != NULL) {//Loop to find all Canon folders 
    553594                               if (de3->d_name[0] != '.' && de3->d_name[1] != '.') {//If item is not UpDir 
    554595                                   sprintf(sub_dir_search, "%s/%s", current_dir, de3->d_name); 
    555                                    d4=opendir(sub_dir_search); 
    556                                    while ((de4=readdir(d4)) != NULL) {//Loop to find a corresponding JPG file inside a Canon folder 
     596                                   d4=safe_opendir(sub_dir_search); 
     597                                   while ((de4=safe_readdir(d4)) != NULL) {//Loop to find a corresponding JPG file inside a Canon folder 
    557598                                       if (de2->d_name[4] == de4->d_name[4] && de2->d_name[5] == de4->d_name[5] &&//If the four digits of the Canon number are the same 
    558599                                           de2->d_name[6] == de4->d_name[6] && de2->d_name[7] == de4->d_name[7] && 
     
    562603                                       }                                  
    563604                                   } 
    564                                    closedir(d4);                  
     605                                   safe_closedir(d4);                  
    565606                               }   
    566607                           } 
    567                            closedir(d3); 
     608                           safe_closedir(d3); 
    568609                           //If no JPG found, delete RAW file 
    569610                           if (found == 0) { 
     
    578619                       } 
    579620                   } 
    580                    closedir(d2); 
     621                   safe_closedir(d2); 
    581622               } 
    582623           } 
    583            closedir(d); 
     624           safe_closedir(d); 
    584625           i=strlen(current_dir); 
    585626           while (current_dir[--i] != '/'); 
     
    589630       else if (selected->name[3] == 'C') { 
    590631           sprintf(current_dir+strlen(current_dir), "/%s", selected->name); 
    591            d=opendir(current_dir); 
    592            while ((de=readdir(d)) != NULL) {//Loop to find all the RAW files inside the Canon folder  
     632           d=safe_opendir(current_dir); 
     633           while ((de=safe_readdir(d)) != NULL) {//Loop to find all the RAW files inside the Canon folder  
    593634               if (de->d_name[0] == 'C' || de->d_name[9] == 'C') {//If file is RAW (Either CRW/CR2 prefix or file extension) 
    594                    d2=opendir(current_dir); 
    595                    while ((de2=readdir(d2)) != NULL) {//Loop to find a corresponding JPG file inside the Canon folder 
     635                   d2=safe_opendir(current_dir); 
     636                   while ((de2=safe_readdir(d2)) != NULL) {//Loop to find a corresponding JPG file inside the Canon folder 
    596637                       if (de->d_name[4] == de2->d_name[4] && de->d_name[5] == de2->d_name[5] &&//If the four digits of the Canon number are the same 
    597638                           de->d_name[6] == de2->d_name[6] && de->d_name[7] == de2->d_name[7] && 
     
    601642                       }                                  
    602643                   } 
    603                    closedir(d2);  
     644                   safe_closedir(d2);  
    604645                   //If no JPG found, delete RAW file                 
    605646                   if (found == 0) { 
     
    614655               } 
    615656           } 
    616            closedir(d); 
     657           safe_closedir(d); 
    617658           i=strlen(current_dir); 
    618659           while (current_dir[--i] != '/'); 
     
    652693//------------------------------------------------------------------- 
    653694static void fselect_delete_folder_cb(unsigned int btn) { 
    654     DIR           *d; 
    655     struct dirent *de; 
     695    STD_DIR           *d; 
     696    struct STD_dirent *de; 
    656697    int           i; 
    657698 
    658699    if (btn==MBOX_BTN_YES) { 
    659700        sprintf(current_dir+strlen(current_dir), "/%s", selected->name); 
    660         d = opendir(current_dir); 
     701        d = safe_opendir(current_dir); 
    661702        if (d) { 
    662             de = readdir(d); 
     703            de = safe_readdir(d); 
    663704            while (de) { 
    664705                if (de->d_name[0] != 0xE5 /* deleted entry */ && (de->d_name[0]!='.' || (de->d_name[1]!='.' && de->d_name[1]!=0) || (de->d_name[1]=='.' && de->d_name[2]!=0))) { 
     
    668709                    finished(); 
    669710                } 
    670                 de = readdir(d); 
    671             } 
    672             closedir(d); 
     711                de = safe_readdir(d); 
     712            } 
     713            safe_closedir(d); 
    673714        } 
    674715        started(); 
     
    778819                        gui_browser_progress_show(lang_str(LANG_FSELECT_PROGRESS_TITLE),i*100/marked_count); 
    779820                    sprintf(selected_file, "%s/%s", marked_dir, ptr->name); 
    780                     fsrc = open(selected_file, O_RDONLY, 0777); 
     821                    fsrc = safe_open(selected_file, O_RDONLY, 0777); 
    781822                    if (fsrc>=0) { 
    782823                        sprintf(selected_file, "%s/%s", current_dir, ptr->name); 
    783824                        // trying to open for read to check if file exists 
    784                         fdst = open(selected_file, O_RDONLY, 0777); 
     825                        fdst = safe_open(selected_file, O_RDONLY, 0777); 
    785826                        if (fdst<0) { 
    786                             fdst = open(selected_file, O_WRONLY|O_CREAT, 0777); 
     827                            fdst = safe_open(selected_file, O_WRONLY|STD_O_CREAT, 0777); 
    787828                            if (fdst>=0) { 
    788829                                do { 
     
    874915 
    875916//------------------------------------------------------------------- 
     917static void fselect_chdk_replace_cb(unsigned int btn) { 
     918    int ss, sd = 0, fsrc, fdst, i=0; 
     919    register int *buf; 
     920    unsigned char fend; 
     921    static struct utimbuf t; 
     922 
     923    if (btn != MBOX_BTN_YES) return; 
     924 
     925    buf = umalloc(MARKED_BUF_SIZE); 
     926    sprintf(selected_file, "%s/%s", current_dir, selected->name); 
     927    fsrc = safe_open(selected_file, O_RDONLY, 0777); 
     928    if (fsrc>=0) { 
     929            strcpy(selected_file,"A/DISKBOOT.BIN"); 
     930            fdst = safe_open(selected_file, O_WRONLY|STD_O_CREAT|STD_O_TRUNC, 0777); 
     931            if (fdst>=0) { 
     932                do { 
     933                    ss=read(fsrc, buf, MARKED_BUF_SIZE); 
     934                    if (ss>0) sd=write(fdst, buf, ss); 
     935                } while (ss>0 && ss==sd); 
     936                close(fdst); 
     937                t.actime = t.modtime = selected->mtime; 
     938                utime(selected_file, &t); 
     939                //shutdown(); 
     940                        gui_browser_progress_show("Please reboot",100); 
     941            } 
     942        if (fsrc>=0) close(fsrc); 
     943    } 
     944    ufree(buf); 
     945} 
     946 
     947//------------------------------------------------------------------- 
    876948static void fselect_marked_inverse_selection() { 
    877949    struct fitem  *ptr; 
     
    887959void process_raw_files(void){ 
    888960 struct fitem *ptr; 
    889  if ((fselect_marked_count()>1) && raw_merge_start(raw_operation)) { 
     961 
     962 librawop_p=module_rawop_load(); 
     963 if (!librawop_p) 
     964        return;         //exit if fail 
     965 
     966 if ((fselect_marked_count()>1) && librawop_p->raw_merge_start(raw_operation)) { 
    890967   for (ptr=head; ptr; ptr=ptr->next) 
    891968     if (ptr->marked && ptr->attr != 0xFF && !(ptr->attr & DOS_ATTR_DIRECTORY)) { 
    892969       sprintf(selected_file, "%s/%s", current_dir, ptr->name); 
    893        raw_merge_add_file(selected_file); 
     970       librawop_p->raw_merge_add_file(selected_file); 
    894971      } 
    895   raw_merge_end(); 
     972  librawop_p->raw_merge_end(); 
    896973  gui_fselect_read_dir(current_dir); 
    897974 } 
     
    904981    char *raw_subtract_dest; 
    905982    if (btn != MBOX_BTN_YES) return; 
     983 
     984        librawop_p=module_rawop_load(); 
     985        if (!librawop_p) 
     986                return;         //exit if fail 
    906987 
    907988    if(!(raw_subtract_from = malloc(300))) //3x full path 
     
    916997            (strcmp(ptr->name,selected->name)) != 0) { 
    917998            sprintf(raw_subtract_from,"%s/%s",current_dir,ptr->name); 
    918             sprintf(raw_subtract_dest,"%s/%s%s",current_dir,img_prefixes[conf.sub_batch_prefix],ptr->name+4); 
    919             strcpy(raw_subtract_dest + strlen(raw_subtract_dest) - 4,img_exts[conf.sub_batch_ext]); 
     999            sprintf(raw_subtract_dest,"%s/%s%s",current_dir,img_prefixes[*conf_sub_batch_prefix],ptr->name+4); 
     1000            strcpy(raw_subtract_dest + strlen(raw_subtract_dest) - 4,img_exts[*conf_sub_batch_ext]); 
    9201001            // don't let users attempt to write one of the files being read 
    9211002            if( strcmp(raw_subtract_dest,raw_subtract_from) != 0 && strcmp(raw_subtract_dest,raw_subtract_sub) != 0) { 
    922                 raw_subtract(raw_subtract_from,raw_subtract_sub,raw_subtract_dest); 
     1003                librawop_p->raw_subtract(raw_subtract_from,raw_subtract_sub,raw_subtract_dest); 
    9231004            } 
    9241005        } 
     
    9551036} 
    9561037//------------------------------------------------------------------- 
    957 #if DNG_SUPPORT 
     1038//#if DNG_SUPPORT 
    9581039void process_dng_to_raw_files(void){ 
    9591040 struct fitem *ptr; 
     
    9681049       sprintf(selected_file, "%s/%s", current_dir, ptr->name); 
    9691050       gui_browser_progress_show(selected_file, (i++)*100/fselect_real_marked_count()) ; 
    970        convert_dng_to_chdk_raw(selected_file); 
     1051       module_convert_dng_to_chdk_raw(selected_file); 
    9711052      } 
    9721053    } 
    9731054 else { 
    9741055   sprintf(selected_file, "%s/%s", current_dir, selected->name); 
    975    convert_dng_to_chdk_raw(selected_file); 
     1056   module_convert_dng_to_chdk_raw(selected_file); 
    9761057 } 
    9771058  gui_fselect_read_dir(current_dir); 
    9781059} 
    979 #endif 
     1060//#endif 
    9801061 
    9811062//------------------------------------------------------------------- 
     
    10471128            raw_prepare_develop(buf); 
    10481129        break; 
     1130        case MPOPUP_CHDK_REPLACE: 
     1131            gui_mbox_init((int)"Replacing CHDK", (int)"Do you want to replace current CHDK with this file", 
     1132                          MBOX_TEXT_CENTER|MBOX_BTN_YES_NO|MBOX_DEF_BTN2, fselect_chdk_replace_cb); 
     1133            break; 
     1134        case MPOPUP_EDITOR: 
     1135            gui_mbox_init((int)"Editor", (int)"edit", MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 
     1136            break; 
    10491137        case MPOPUP_SUBTRACT: 
    10501138        { 
     
    10521140            break; 
    10531141        } 
    1054 #if DNG_SUPPORT 
     1142//#if DNG_SUPPORT 
    10551143    case MPOPUP_DNG_TO_CRW: 
    10561144            process_dng_to_raw_files(); 
    10571145            break; 
    1058 #endif 
     1146//#endif 
    10591147    } 
    10601148    gui_fselect_redraw = 2; 
     
    10621150 
    10631151//------------------------------------------------------------------- 
    1064 static void exit_fselect(char* file) 
     1152void finalize_fselect() 
    10651153{ 
    10661154    gui_fselect_free_data(); 
    10671155    gui_fselect_marked_free_data(); 
     1156        module_rawop_unload(); 
     1157} 
     1158 
     1159static void exit_fselect(char* file) 
     1160{ 
     1161        finalize_fselect(); 
     1162 
    10681163    if (set_key_redraw_mode) 
    10691164    { 
     
    10741169    { 
    10751170        fselect_on_select(file); 
     1171        // if called mode will return control to filemanager - we need to redraw it 
     1172        gui_fselect_redraw = 2; 
    10761173    } 
    10771174    if (!set_key_redraw_mode) 
     
    10821179} 
    10831180 
     1181//------------------------------------------------------------------- 
    10841182void gui_fselect_kbd_process() { 
    10851183    int i; 
     
    11401238                if(selected->size == hook_raw_size()) 
    11411239                    i |= MPOPUP_RAW_DEVELOP; 
    1142 #if DNG_SUPPORT 
     1240//#if DNG_SUPPORT 
    11431241                if((fselect_marked_count()>1)||(selected->size > hook_raw_size())) 
    11441242                    i |= MPOPUP_DNG_TO_CRW; 
    1145 #endif 
    1146                 gui_mpopup_init(i, fselect_mpopup_cb); 
     1243//#endif 
     1244 
     1245                if (selected->name[9] == 'B' && selected->name[10] == 'I' && selected->name[11] == 'N') //If item is DCIM folder 
     1246                    i |= MPOPUP_CHDK_REPLACE; 
     1247 
     1248                module_mpopup_init( popup, i, fselect_mpopup_cb, 0); 
    11471249            } 
    11481250            break; 
     
    11611263                } else  { 
    11621264                    sprintf(selected_file, "%s/%s", current_dir, selected->name); 
     1265                                         
     1266                                        char *ext = strchr(selected->name,'.'); 
     1267                    if ( ext && (ext[1]|0x20)=='f' && (ext[2]|0x20)=='l' && (ext[3]|0x20)=='t') { 
     1268                                        if (!fselect_on_select) { 
     1269                                exit_fselect(0); 
     1270                                                module_run(selected_file, 0, 0,0, UNLOAD_IF_ERR); 
     1271 
     1272                                                        break; 
     1273                                                } 
     1274                                        } 
     1275 
    11631276                    exit_fselect(selected_file); 
     1277                                        module_async_unload(module_idx); 
    11641278                } 
    11651279            } 
    11661280            break; 
    1167       #if CAM_HAS_ERASE_BUTTON 
    11681281        case KEY_ERASE: 
    1169       #else 
    11701282        case KEY_DISPLAY: 
    1171       #endif 
    11721283            if (selected && selected->attr != 0xFF) { 
    11731284                if (selected->attr & DOS_ATTR_DIRECTORY) { 
     
    11841295            // just free resource. callback called with NULL ptr 
    11851296            exit_fselect(0); 
    1186             break; 
    1187     } 
    1188 } 
    1189  
    1190 //------------------------------------------------------------------- 
     1297                        module_async_unload(module_idx); 
     1298            break; 
     1299    } 
     1300} 
     1301 
     1302 
     1303 
     1304// =========  MODULE INIT ================= 
     1305#include "module_load.h" 
     1306int module_idx=-1; 
     1307 
     1308/***************** BEGIN OF AUXILARY PART ********************* 
     1309  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     1310 **************************************************************/ 
     1311 
     1312void* MODULE_EXPORT_LIST[] = { 
     1313        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     1314        /* 1 */ (void*)0 
     1315                }; 
     1316 
     1317 
     1318//--------------------------------------------------------- 
     1319// PURPOSE:   Bind module symbols with chdk.  
     1320//              Required function 
     1321// PARAMETERS: pointer to chdk list of export 
     1322// RETURN VALUE: 1 error, 0 ok 
     1323//--------------------------------------------------------- 
     1324int _module_loader( void** chdk_export_list ) 
     1325{ 
     1326  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     1327     return 1; 
     1328 
     1329  tConfigVal configVal; 
     1330  CONF_BIND_INT(209, conf_sub_batch_prefix); 
     1331  CONF_BIND_INT(210, conf_sub_batch_ext); 
     1332 
     1333  // Try to bind to generic gui mode alias 
     1334  if (!gui_bind_mode( GUI_MODE_FSELECT, &GUI_MODE_FSELECT_MODULE)) 
     1335        return 1; 
     1336 
     1337  return 0; 
     1338} 
     1339 
     1340 
     1341 
     1342//--------------------------------------------------------- 
     1343// PURPOSE: Finalize module operations (close allocs, etc) 
     1344// RETURN VALUE: 0-ok, 1-fail 
     1345//--------------------------------------------------------- 
     1346int _module_unloader() 
     1347{ 
     1348        finalize_fselect(); 
     1349 
     1350        //sanity clean to prevent accidentaly assign/restore guimode to unloaded module  
     1351        GUI_MODE_FSELECT_MODULE.magicnum = 0; 
     1352 
     1353    // Unbind generic alias 
     1354        gui_bind_mode( GUI_MODE_FSELECT, 0); 
     1355 
     1356    return 0; 
     1357} 
     1358 
     1359 
     1360//--------------------------------------------------------- 
     1361// PURPOSE: Default action for simple modules (direct run) 
     1362// NOTE: Please comment this function if no default action and this library module 
     1363//--------------------------------------------------------- 
     1364int _module_run(int moduleidx, int argn, int* arguments) 
     1365{ 
     1366  module_idx=moduleidx; 
     1367 
     1368  if ( argn!=0 && argn!=5 ) { 
     1369        module_async_unload(moduleidx); 
     1370    return 1; 
     1371  } 
     1372 
     1373  // Autounloading is unsafe because it should exists to catch finalization of mpopup 
     1374  module_set_flags(module_idx, MODULE_FLAG_DISABLE_AUTOUNLOAD); 
     1375 
     1376  if ( argn == 5 ) { 
     1377  gui_fselect_init( arguments[0], (const char*) arguments[1], (const char*) arguments[2], (void*)arguments[3]); 
     1378  gui_fselect_set_key_redraw(arguments[4]); 
     1379  } 
     1380  else 
     1381    gui_fselect_init(LANG_STR_FILE_BROWSER, "A", "A", NULL); 
     1382 
     1383  return 0; 
     1384} 
     1385 
     1386 
     1387/******************** Module Information structure ******************/ 
     1388 
     1389struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     1390                                                                        sizeof(struct ModuleInfo), 
     1391 
     1392                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     1393                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     1394                                                                        0,                                                      // flag 
     1395                                                                        -LANG_MENU_MISC_FILE_BROWSER,   // Module name 
     1396                                                                        1, 0,                                           // Module version 
     1397                                                                        0 
     1398                                                                 }; 
     1399 
     1400/*************** END OF AUXILARY PART *******************/ 
  • trunk/core/gui_fselect.h

    r1423 r1505  
    66extern char* gui_fselect_result(); 
    77extern void gui_fselect_kbd_process(); 
    8 extern void gui_fselect_draw(); 
     8extern void gui_fselect_draw(int enforce_redraw); 
    99extern void gui_fselect_force_redraw(); 
     10extern void finalize_fselect(); 
    1011//------------------------------------------------------------------- 
    1112#endif 
  • trunk/core/gui_mastermind.c

    • Property svn:eol-style set to native
    r1338 r1505  
    1212#include "gui_mastermind.h" 
    1313 
     14#include "module_load.h" 
     15void gui_module_menu_kbd_process(); 
     16 
     17gui_handler GUI_MODE_MASTERMIND =  
     18    /*GUI_MODE_MASTERMIND*/     { gui_mastermind_draw,  gui_mastermind_kbd_process, gui_module_menu_kbd_process, GUI_MODE_FLAG_NODRAWRESTORE, GUI_MODE_MAGICNUM }; 
     19 
     20 
    1421#define BORDER                          20 
    1522#define RECT_SIZE                       10 
     
    2128int curr_y; 
    2229int answer[4]; 
    23 char colors[6] = { COLOR_HISTO_R_PLAY, COLOR_HISTO_G_PLAY, COLOR_HISTO_B_PLAY, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK }; 
     30char colors[6]; 
    2431int curr_color[4]; 
    2532int GameGo; 
     
    133140        for(i=0;i<4;i++) curr_color[i]=99; 
    134141         
     142    gui_set_mode((unsigned int)&GUI_MODE_MASTERMIND); 
    135143        return 1; 
    136144} 
     145 
    137146//------------------------------------------------------------------- 
    138147static void draw_box(color border) 
     
    217226} 
    218227//------------------------------------------------------------------- 
    219 void gui_mastermind_draw() { 
     228void gui_mastermind_draw(int enforce_redraw) { 
    220229        unsigned long t; 
    221230    static struct tm *ttm; 
     
    228237    draw_txt_string((screen_width-CAM_TS_BUTTON_BORDER)/FONT_WIDTH-2-1-1-9-2-5-4, screen_height/FONT_HEIGHT-1, buf, TEXT_COLOR); 
    229238} 
     239 
     240 
     241int basic_module_init() { 
     242        colors[0] = COLOR_HISTO_R_PLAY; 
     243        colors[1] = COLOR_HISTO_G_PLAY; 
     244        colors[2] = COLOR_HISTO_B_PLAY; 
     245        colors[3] = COLOR_YELLOW; 
     246        colors[4] = COLOR_WHITE; 
     247        colors[5] = COLOR_BLACK; 
     248 
     249        return gui_mastermind_init();  
     250} 
     251 
     252extern int module_idx; 
     253void gui_module_menu_kbd_process() { 
     254        gui_default_kbd_process_menu_btn(); 
     255        module_async_unload(module_idx); 
     256} 
     257 
     258/******************** Module Information structure ******************/ 
     259 
     260struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     261                                                                        sizeof(struct ModuleInfo), 
     262 
     263                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     264                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     265                                                                        0,                                                      // flag 
     266                                                                        -LANG_MENU_GAMES_MASTERMIND,// Module name 
     267                                                                        1, 0,                                           // Module version 
     268                                                                        (int32_t)"Game" 
     269                                                                 }; 
  • trunk/core/gui_mastermind.h

    • Property svn:eol-style set to native
    r649 r1505  
    55extern int gui_mastermind_init(); 
    66extern void gui_mastermind_kbd_process(); 
    7 extern void gui_mastermind_draw(); 
     7extern void gui_mastermind_draw(int enforce_redraw); 
    88 
    99//------------------------------------------------------------------- 
  • trunk/core/gui_mbox.c

    r1431 r1505  
    1111 
    1212//------------------------------------------------------------------- 
    13 static enum Gui_Mode    gui_mbox_mode_old; 
     13static gui_mode_t       gui_mbox_mode_old; 
    1414static const char*      mbox_title; 
    1515static const char*      mbox_msg; 
     
    8686 
    8787//------------------------------------------------------------------- 
    88 void gui_mbox_draw() { 
     88void gui_mbox_draw(int enforce_redraw) { 
    8989    if (mbox_to_draw) { 
    9090        char c[MAX_LINES][MAX_WIDTH+1]; 
     
    172172 
    173173//------------------------------------------------------------------- 
     174 
     175void gui_browser_progress_show(const char* msg, const unsigned int perc) { 
     176    coord x=60, y=100; 
     177    unsigned int w=240, h=40, len; 
     178 
     179    draw_rect_shadow(x+1, y+1, x+w+1, y+h+1, COLOR_BLACK, 3); //shadow 
     180    draw_filled_rect(x, y, x+w, y+h, MAKE_COLOR(COLOR_GREY, COLOR_WHITE)); // main box 
     181    len = strlen(msg); 
     182    draw_string(x+((w-len*FONT_WIDTH)>>1), y+2, msg, MAKE_COLOR(COLOR_GREY, COLOR_WHITE)); //title text 
     183    draw_filled_rect(x+10, y+4+FONT_HEIGHT, x+w-10, y+h-10, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); // progress rect 
     184    draw_filled_rect(x+11, y+5+FONT_HEIGHT, x+11+(w-22)*perc/100, y+h-11, MAKE_COLOR(COLOR_RED, COLOR_RED)); // progress bar 
     185} 
  • trunk/core/gui_mbox.h

    r515 r1505  
    2727extern void gui_mbox_init(int title, int msg, const unsigned int flags, void (*on_select)(unsigned int btn)); 
    2828extern void gui_mbox_kbd_process(); 
    29 extern void gui_mbox_draw(); 
     29extern void gui_mbox_draw(int enforce_redraw); 
     30 
     31extern void gui_browser_progress_show(const char* msg, const unsigned int perc); 
    3032 
    3133//------------------------------------------------------------------- 
  • trunk/core/gui_menu.c

    r1425 r1505  
    88#include "gui.h" 
    99#include "gui_draw.h" 
    10 #include "gui_palette.h" 
     10#include "modules.h" 
    1111#include "gui_menu.h" 
    1212#include "gui_lang.h" 
     
    7777    for(n = 0; curr_menu->menu[n].text; n++); 
    7878    return n; 
    79 } 
    80  
    81 //------------------------------------------------------------------- 
    82 // Called from other gui functions to force redraw of menu 
    83 void gui_menu_force_redraw() 
    84 { 
    85     if (gui_get_mode() == GUI_MODE_MENU) 
    86     { 
    87         gui_menu_redraw = 2; 
    88     } 
    8979} 
    9080 
     
    523513                    case MENUITEM_COLOR_FG: 
    524514                    case MENUITEM_COLOR_BG: 
    525                         draw_restore(); 
    526515                        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); 
    527                         gui_palette_init(PALETTE_MODE_SELECT, (*item_color)&0xFF, gui_menu_color_selected); 
    528                         gui_set_mode(GUI_MODE_PALETTE); 
     516                        module_palette_run(PALETTE_MODE_SELECT, (*item_color)&0xFF, gui_menu_color_selected); 
    529517                        gui_menu_redraw=2; 
    530518                        break; 
     
    680668 
    681669//------------------------------------------------------------------- 
    682 void gui_menu_draw() { 
     670void gui_menu_draw(int enforce_redraw) { 
    683671    static char tbuf[64]; 
    684672    int i, j; 
    685673    const char *ch = ""; 
     674 
     675        if ( enforce_redraw ) 
     676                gui_menu_redraw = 2; 
    686677 
    687678    if (gui_menu_redraw) 
  • trunk/core/gui_menu.h

    r1407 r1505  
    5050typedef struct { 
    5151    char                symbol; 
    52     short               title; 
     52    int                 title; 
    5353    void                (*on_change)(unsigned int item); 
    5454    const CMenuItem     *menu; 
     
    6363extern void gui_menu_init(CMenu *menu_ptr); 
    6464extern void gui_menu_kbd_process(); 
    65 extern void gui_menu_draw(); 
     65extern void gui_menu_draw(int enforce_redraw); 
    6666extern void mod_user_menu(CMenuItem curr_menu_item, int* gui_menu_add_item, int mod); 
    6767extern void gui_menu_force_redraw(); 
    6868//------------------------------------------------------------------- 
     69 
     70// declared in gui.c 
     71extern CMenuItem* find_mnu(CMenu *curr_menu, int item); 
     72 
    6973#endif 
  • trunk/core/gui_mpopup.c

    r1407 r1505  
    99#include "gui_mpopup.h" 
    1010 
     11#include "module_load.h" 
     12 
     13extern int module_idx; 
     14 
     15gui_handler GUI_MODE_MPOPUP_MODULE =  
     16    /*GUI_MODE_MPOPUP*/         { gui_mpopup_draw,      gui_mpopup_kbd_process,     gui_mpopup_kbd_process, GUI_MODE_FLAG_NORESTORE_ON_SWITCH, GUI_MODE_MAGICNUM }; 
     17 
    1118// Simple popup menu. No title, no separators, only processing items 
    1219 
    1320//------------------------------------------------------------------- 
    14 static enum Gui_Mode            gui_mpopup_mode_old; 
     21static gui_mode_t          gui_mpopup_mode_old; 
    1522static char                     mpopup_to_draw; 
    1623 
    17 static struct { 
    18         unsigned int            flag; 
    19         int                     text; 
    20 } actions[] = { 
    21         { MPOPUP_CUT,           LANG_POPUP_CUT    }, 
    22         { MPOPUP_COPY,          LANG_POPUP_COPY   }, 
    23         { MPOPUP_PASTE,         LANG_POPUP_PASTE  }, 
    24         { MPOPUP_DELETE,        LANG_POPUP_DELETE }, 
    25         { MPOPUP_SELINV,        LANG_POPUP_SELINV }, 
    26         { MPOPUP_RAW_ADD,       LANG_POPUP_RAW_SUM}, 
    27         { MPOPUP_RAW_AVERAGE,   LANG_POPUP_RAW_AVERAGE }, 
    28         { MPOPUP_RAW_DEVELOP,   LANG_MENU_RAW_DEVELOP }, 
    29         { MPOPUP_PURGE,         LANG_POPUP_PURGE  }, 
    30         { MPOPUP_SUBTRACT,      LANG_POPUP_SUB_FROM_MARKED  }, 
    31 #if DNG_SUPPORT 
    32         { MPOPUP_DNG_TO_CRW,    (int)"DNG -> CHDK RAW"}, 
    33 #endif 
    34 }; 
    35  
    36 #define ACTIONSNUM              (sizeof(actions)/sizeof(actions[0])) 
    3724#define MAX_ACTIONS             10 
     25 
     26struct mpopup_item* actions; 
    3827 
    3928static int                      mpopup_actions[MAX_ACTIONS];    // Content of raised popupmenu 
     
    4534 
    4635//------------------------------------------------------------------- 
    47 void gui_mpopup_init(const unsigned int flags, void (*on_select)(unsigned int actn)) { 
     36void gui_mpopup_init(struct mpopup_item* popup_actions, const unsigned int flags, void (*on_select)(unsigned int actn), int mode)  
     37{ 
    4838    int i; 
    4939 
    5040    mpopup_actions_num = 0; 
    51     for (i=0; i<ACTIONSNUM && mpopup_actions_num<MAX_ACTIONS; ++i) { 
     41    actions = popup_actions; 
     42    for (i=0; actions[i].flag && mpopup_actions_num<MAX_ACTIONS; ++i) { 
    5243        if (flags & MPOPUP_MASK & actions[i].flag) 
    5344            mpopup_actions[mpopup_actions_num++] = i; 
    5445    } 
    55     if (mpopup_actions_num == 0) 
     46    if (mpopup_actions_num == 0) { 
    5647        on_select(MPOPUP_CANCEL); 
     48                return; 
     49        } 
    5750 
    5851    mpopup_actions_active = 0; 
     
    6154    mpopup_to_draw = 1; 
    6255    mpopup_on_select = on_select; 
    63     gui_set_mode(GUI_MODE_MPOPUP); 
     56    gui_set_mode((unsigned int)&GUI_MODE_MPOPUP_MODULE); 
    6457} 
    6558 
     
    8578 
    8679//------------------------------------------------------------------- 
    87 void gui_mpopup_draw() { 
     80void gui_mpopup_draw(int enforce_redraw) { 
    8881    if (mpopup_to_draw) { 
    8982        int i; 
     
    114107 
    115108//------------------------------------------------------------------- 
     109void exit_mpopup(int action) 
     110{ 
     111    gui_set_mode(gui_mpopup_mode_old); 
     112    if (mpopup_on_select)  
     113        mpopup_on_select(action); 
     114        mpopup_on_select=0; 
     115} 
     116 
     117//------------------------------------------------------------------- 
    116118void gui_mpopup_kbd_process() { 
    117119    switch (kbd_get_clicked_key() | get_jogdial_direction()) { 
     
    131133    case KEY_LEFT: 
    132134        kbd_reset_autoclicked_key(); 
    133         gui_set_mode(gui_mpopup_mode_old); 
    134         if (mpopup_on_select)  
    135             mpopup_on_select(MPOPUP_CANCEL); 
     135                exit_mpopup(MPOPUP_CANCEL);              
     136                module_async_unload(module_idx); 
    136137        break; 
    137138    case KEY_SET: 
    138139        kbd_reset_autoclicked_key(); 
    139         gui_set_mode(gui_mpopup_mode_old); 
    140         if (mpopup_on_select)  
    141             mpopup_on_select(actions[mpopup_actions[mpopup_actions_active]].flag); 
    142         break; 
    143     } 
    144 } 
    145  
    146 //------------------------------------------------------------------- 
    147 void gui_browser_progress_show(const char* msg, const unsigned int perc) { 
    148     coord x=60, y=100; 
    149     unsigned int w=240, h=40, len; 
    150  
    151     draw_rect_shadow(x+1, y+1, x+w+1, y+h+1, COLOR_BLACK, 3); //shadow 
    152     draw_filled_rect(x, y, x+w, y+h, MAKE_COLOR(COLOR_GREY, COLOR_WHITE)); // main box 
    153     len = strlen(msg); 
    154     draw_string(x+((w-len*FONT_WIDTH)>>1), y+2, msg, MAKE_COLOR(COLOR_GREY, COLOR_WHITE)); //title text 
    155     draw_filled_rect(x+10, y+4+FONT_HEIGHT, x+w-10, y+h-10, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); // progress rect 
    156     draw_filled_rect(x+11, y+5+FONT_HEIGHT, x+11+(w-22)*perc/100, y+h-11, MAKE_COLOR(COLOR_RED, COLOR_RED)); // progress bar 
    157 } 
     140                exit_mpopup(actions[mpopup_actions[mpopup_actions_active]].flag);                
     141                module_async_unload(module_idx); 
     142        break; 
     143    } 
     144} 
     145 
     146//------------------------------------------------------------------- 
     147 
     148// =========  MODULE INIT ================= 
     149 
     150int module_idx=-1; 
     151 
     152/***************** BEGIN OF AUXILARY PART ********************* 
     153  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     154 **************************************************************/ 
     155 
     156void* MODULE_EXPORT_LIST[] = { 
     157        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     158        /* 1 */ (void*)0 
     159                }; 
     160 
     161 
     162//--------------------------------------------------------- 
     163// PURPOSE:   Bind module symbols with chdk.  
     164//              Required function 
     165// PARAMETERS: pointer to chdk list of export 
     166// RETURN VALUE: 1 error, 0 ok 
     167//--------------------------------------------------------- 
     168int _module_loader( void** chdk_export_list ) 
     169{ 
     170  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     171     return 1; 
     172 
     173  // Try to bind to generic gui mode alias 
     174  if (!gui_bind_mode( GUI_MODE_MPOPUP, &GUI_MODE_MPOPUP_MODULE)) 
     175     return 1; 
     176 
     177  return 0; 
     178} 
     179 
     180 
     181 
     182//--------------------------------------------------------- 
     183// PURPOSE: Finalize module operations (close allocs, etc) 
     184// RETURN VALUE: 0-ok, 1-fail 
     185//--------------------------------------------------------- 
     186int _module_unloader() 
     187{ 
     188    if (mpopup_on_select)  
     189        mpopup_on_select(MPOPUP_CANCEL); 
     190 
     191        //sanity clean to prevent accidentaly assign/restore guimode to unloaded module  
     192        GUI_MODE_MPOPUP_MODULE.magicnum = 0; 
     193 
     194        // unbind generic alias 
     195        gui_bind_mode( GUI_MODE_MPOPUP, 0 ); 
     196 
     197    return 0; 
     198} 
     199 
     200 
     201//--------------------------------------------------------- 
     202// PURPOSE: Default action for simple modules (direct run) 
     203// NOTE: Please comment this function if no default action and this library module 
     204//--------------------------------------------------------- 
     205int _module_run(int moduleidx, int argn, int* arguments) 
     206{ 
     207  module_idx=moduleidx; 
     208 
     209  if ( argn!=4) { 
     210        module_async_unload(moduleidx); 
     211    return 1; 
     212  } 
     213 
     214  // Currently only old (0) mode is supported 
     215  // This is for load error if newer version is required 
     216  if (arguments[3]!=0) 
     217                return 1; 
     218 
     219  gui_mpopup_init( (struct mpopup_item*)arguments[0], (const unsigned int)arguments[1], (void*) arguments[2], arguments[3]); 
     220   
     221 
     222  return 0; 
     223} 
     224 
     225 
     226/******************** Module Information structure ******************/ 
     227 
     228struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     229                                                                        sizeof(struct ModuleInfo), 
     230 
     231                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     232                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     233                                                                        MODULEINFO_FLAG_SYSTEM,         // flag 
     234                                                                        (int32_t)"Popup menu module",           // Module name 
     235                                                                        1, 0,                                           // Module version 
     236                                                                        0 
     237                                                                 }; 
     238 
     239/*************** END OF AUXILARY PART *******************/ 
  • trunk/core/gui_mpopup.h

    r666 r1505  
    33 
    44//------------------------------------------------------------------- 
    5 #define MPOPUP_MASK             0x07FF 
    6 #define MPOPUP_CANCEL           0x0800 
    7 #define MPOPUP_CUT              0x0001 
    8 #define MPOPUP_COPY             0x0002 
    9 #define MPOPUP_PASTE            0x0004 
    10 #define MPOPUP_DELETE           0x0008 
    11 #define MPOPUP_SELINV           0x0010 
    12 #define MPOPUP_RAW_ADD          0x0020 
    13 #define MPOPUP_RAW_AVERAGE      0x0040 
    14 #define MPOPUP_PURGE            0x0080 
    15 #define MPOPUP_SUBTRACT         0x0100 
    16 #define MPOPUP_RAW_DEVELOP      0x0200 
    17 #define MPOPUP_DNG_TO_CRW       0x0400 
     5#define MPOPUP_MASK             0x7FFF 
     6#define MPOPUP_CANCEL           0x8000 
     7 
     8struct mpopup_item { 
     9        unsigned int            flag; 
     10        int                     text; 
     11}; 
    1812 
    1913//------------------------------------------------------------------- 
    20 extern void gui_mpopup_init(const unsigned int flags, void (*on_select)(unsigned int actn)); 
     14extern void gui_mpopup_init(struct mpopup_item* popup_actions, const unsigned int flags, void (*on_select)(unsigned int actn), int mode); 
    2115extern void gui_mpopup_kbd_process(); 
    22 extern void gui_mpopup_draw(); 
    23  
    24 extern void gui_browser_progress_show(const char* msg, const unsigned int perc); 
     16extern void gui_mpopup_draw(int enforce_redraw); 
    2517 
    2618//------------------------------------------------------------------- 
  • trunk/core/gui_osd.c

    r1499 r1505  
    105105 
    106106//------------------------------------------------------------------- 
    107 void gui_osd_draw() { 
     107void gui_osd_draw(int enforce_redraw) { 
    108108    if (osd_to_draw) { 
    109109        int i; 
  • trunk/core/gui_osd.h

    r683 r1505  
    3636extern void gui_osd_init(); 
    3737extern void gui_osd_kbd_process(); 
    38 extern void gui_osd_draw(); 
     38extern void gui_osd_draw(int enforce_redraw); 
    3939 
    4040extern void gui_osd_draw_histo(); 
  • trunk/core/gui_palette.c

    r1338 r1505  
    1010#include "gui_palette.h" 
    1111 
     12 
     13#include "module_load.h" 
     14void gui_module_menu_kbd_process(); 
     15 
     16gui_handler GUI_MODE_PALETTE_MODULE =  
     17    /*GUI_MODE_PALETTE*/        { gui_palette_draw,     gui_palette_kbd_process,    gui_module_menu_kbd_process, 0, GUI_MODE_MAGICNUM }; 
     18 
    1219//------------------------------------------------------------------- 
    1320static color cl; 
     
    1825//------------------------------------------------------------------- 
    1926void gui_palette_init(int mode, color st_color, void (*on_select)(color clr)) { 
     27        draw_restore(); 
    2028    cl = st_color; 
    2129    palette_mode = mode; 
    2230    palette_on_select = on_select; 
    2331    gui_palette_redraw = 1; 
     32        gui_set_mode((unsigned int)&GUI_MODE_PALETTE_MODULE); 
    2433} 
    2534 
     
    4958                if (palette_on_select)  
    5059                    palette_on_select(cl); 
    51                 gui_set_mode(GUI_MODE_MENU); 
     60                gui_module_menu_kbd_process(); 
    5261            } 
    5362            break; 
     
    6473#define DISP_BOTTOM         (FONT_HEIGHT + BORDER_SIZE + CELL_SIZE * 16) 
    6574 
    66 void gui_palette_draw() { 
     75void gui_palette_draw(int enforce_redraw) { 
    6776    unsigned int x, y, xl, xr; 
    6877    char f=0; 
     
    108117} 
    109118 
     119extern int module_idx; 
     120void gui_module_menu_kbd_process() { 
     121        gui_default_kbd_process_menu_btn(); 
     122        module_async_unload(module_idx); 
     123} 
     124 
     125// =========  MODULE INIT ================= 
     126#include "module_load.h" 
     127int module_idx=-1; 
     128 
     129/***************** BEGIN OF AUXILARY PART ********************* 
     130  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     131 **************************************************************/ 
     132 
     133void* MODULE_EXPORT_LIST[] = { 
     134        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     135        /* 1 */ (void*)0 
     136                }; 
     137 
     138 
     139//--------------------------------------------------------- 
     140// PURPOSE:   Bind module symbols with chdk.  
     141//              Required function 
     142// PARAMETERS: pointer to chdk list of export 
     143// RETURN VALUE: 1 error, 0 ok 
     144//--------------------------------------------------------- 
     145int _module_loader( void** chdk_export_list ) 
     146{ 
     147  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     148     return 1; 
     149 
     150  // Try to bind to generic gui mode alias 
     151  if (!gui_bind_mode( GUI_MODE_PALETTE, &GUI_MODE_PALETTE_MODULE)) 
     152        return 1; 
     153 
     154  return 0; 
     155} 
     156 
     157 
     158 
     159//--------------------------------------------------------- 
     160// PURPOSE: Finalize module operations (close allocs, etc) 
     161// RETURN VALUE: 0-ok, 1-fail 
     162//--------------------------------------------------------- 
     163int _module_unloader() 
     164{ 
     165  //sanity clean to prevent accidentaly assign/restore guimode to unloaded module  
     166  GUI_MODE_PALETTE_MODULE.magicnum = 0; 
     167 
     168  // unbind generic alias 
     169  gui_bind_mode( GUI_MODE_PALETTE, 0); 
     170 
     171  return 0; 
     172} 
     173 
     174 
     175//--------------------------------------------------------- 
     176// PURPOSE: Default action for simple modules (direct run) 
     177// NOTE: Please comment this function if no default action and this library module 
     178//--------------------------------------------------------- 
     179int _module_run(int moduleidx, int argn, int* arguments) 
     180{ 
     181  module_idx=moduleidx; 
     182 
     183  if ( argn!=0 && argn!=3) { 
     184        module_async_unload(moduleidx); 
     185    return 1; 
     186  } 
     187 
     188  if ( argn==3 ) 
     189  gui_palette_init( arguments[0], (color)arguments[1], (void*)arguments[2]); 
     190  else 
     191        gui_palette_init( PALETTE_MODE_DEFAULT, 0x00, NULL ); 
     192 
     193  return 0; 
     194} 
     195 
     196/******************** Module Information structure ******************/ 
     197 
     198struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     199                                                                        sizeof(struct ModuleInfo), 
     200 
     201                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     202                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     203                                                                        0,                                                      // flag 
     204                                                                        (int32_t)"Palette",                                     // Module name 
     205                                                                        1, 0,                                           // Module version 
     206                                                                        0 
     207                                                                 }; 
     208 
     209/*************** END OF AUXILARY PART *******************/ 
  • trunk/core/gui_palette.h

    r515 r1505  
    1212extern void gui_palette_init(int mode, color st_color, void (*on_select)(color clr)); 
    1313extern void gui_palette_kbd_process(); 
    14 extern void gui_palette_draw(); 
     14extern void gui_palette_draw(int enforce_redraw); 
    1515 
    1616//------------------------------------------------------------------- 
  • trunk/core/gui_read.c

    r1338 r1505  
    1111 
    1212 
     13#include "module_load.h" 
     14 
     15extern void gui_read_kbd_process_menu_btn(); 
     16 
     17int *conf_reader_autoscroll; 
     18int *conf_reader_autoscroll_delay; 
     19int *conf_reader_pos; 
     20int *conf_reader_wrap_by_words; 
     21color *conf_reader_color; 
     22char *conf_reader_file; 
     23char *conf_menu_rbf_file; 
     24 
     25gui_handler GUI_MODE_READ =  
     26    /*GUI_MODE_READ*/           { gui_read_draw,        gui_read_kbd_process,       gui_read_kbd_process_menu_btn,      0,      GUI_MODE_MAGICNUM }; 
     27 
    1328//------------------------------------------------------------------- 
    1429static int read_file; 
     
    2338static int pause; 
    2439 
     40static int reader_is_active;    // Flag raised when reader is succesfully runned 
     41                                                                // purpose: we shouldn't process "leave" sequence if we call unload module but reader was not runed yet 
     42 
    2543//------------------------------------------------------------------- 
    2644static void gui_read_draw_batt() { 
     
    4260//------------------------------------------------------------------- 
    4361static void gui_read_draw_scroll_indicator() { 
    44     draw_txt_char((screen_width-CAM_TS_BUTTON_BORDER)/FONT_WIDTH-2, 0, (conf.reader_autoscroll)?((pause)?'\x05':'\x04'):'\x03', MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline 
     62    draw_txt_char((screen_width-CAM_TS_BUTTON_BORDER)/FONT_WIDTH-2, 0, (*conf_reader_autoscroll)?((pause)?'\x05':'\x04'):'\x03', MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline 
    4563} 
    4664 
    4765//------------------------------------------------------------------- 
    4866int gui_read_init(const char* file) { 
    49     static struct stat   st; 
    50     read_file = open(file, O_RDONLY, 0777); 
    51     if (strcmp(file, conf.reader_file)!=0) { 
    52         conf.reader_pos = 0; 
    53         strcpy(conf.reader_file, file); 
     67    static struct STD_stat   st; 
     68    read_file = safe_open(file, O_RDONLY, 0777); 
     69    if (strcmp(file, conf_reader_file)!=0) { 
     70        *conf_reader_pos = 0; 
     71        strcpy(conf_reader_file, file); 
    5472    } 
    5573    read_on_screen = 0; 
    56     read_file_size = (read_file>=0 && stat((char*)file, &st)==0)?st.st_size:0; 
    57     if (read_file_size<=conf.reader_pos) { 
    58         conf.reader_pos = 0; 
     74    read_file_size = (read_file>=0 && safe_stat((char*)file, &st)==0)?st.st_size:0; 
     75    if (read_file_size<=*conf_reader_pos) { 
     76        *conf_reader_pos = 0; 
    5977    } 
    6078    pause = 0; 
     
    6684    last_time = get_tick_count(); 
    6785     
     86        reader_is_active=1;     
     87    gui_set_mode((unsigned int)&GUI_MODE_READ); 
     88 
    6889    draw_filled_rect(0, 0, screen_width-1, y-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 
    69     draw_filled_rect(0, y, screen_width-1, screen_height-1, MAKE_COLOR((conf.reader_color>>8)&0xFF, (conf.reader_color>>8)&0xFF)); 
     90    draw_filled_rect(0, y, screen_width-1, screen_height-1, MAKE_COLOR((*conf_reader_color>>8)&0xFF, (*conf_reader_color>>8)&0xFF)); 
    7091 
    7192    gui_read_draw_scroll_indicator(); 
     
    7798//------------------------------------------------------------------- 
    7899static void read_goto_next_line() { 
    79     draw_filled_rect(xx, yy, x+w-1, yy+rbf_font_height()-1, MAKE_COLOR(conf.reader_color>>8, conf.reader_color>>8)); 
     100    draw_filled_rect(xx, yy, x+w-1, yy+rbf_font_height()-1, MAKE_COLOR(*conf_reader_color>>8, *conf_reader_color>>8)); 
    80101    xx  = x; 
    81102    yy += rbf_font_height(); 
     
    88109 
    89110//------------------------------------------------------------------- 
    90 void gui_read_draw() { 
    91     if (conf.reader_autoscroll && !pause && get_tick_count()-last_time >= conf.reader_autoscroll_delay*1000 && (conf.reader_pos+read_on_screen)<read_file_size) { 
    92         conf.reader_pos += read_on_screen; 
     111void gui_read_draw(int enforce_redraw) { 
     112    if (*conf_reader_autoscroll && !pause && get_tick_count()-last_time >= *conf_reader_autoscroll_delay*1000 && (*conf_reader_pos+read_on_screen)<read_file_size) { 
     113        *conf_reader_pos += read_on_screen; 
    93114        read_to_draw = 1; 
    94115    } 
     
    98119        xx=x; yy=y; 
    99120 
    100         lseek(read_file, conf.reader_pos, SEEK_SET); 
     121        lseek(read_file, *conf_reader_pos, SEEK_SET); 
    101122        read_on_screen=0; 
    102123 
     
    106127                 read_goto_next_line(); 
    107128                 if (yy < y+h) 
    108                      draw_filled_rect(x, yy, x+w-1, y+h-1, MAKE_COLOR(conf.reader_color>>8, conf.reader_color>>8)); 
     129                     draw_filled_rect(x, yy, x+w-1, y+h-1, MAKE_COLOR(*conf_reader_color>>8, *conf_reader_color>>8)); 
    109130                 break; 
    110131            } 
     
    123144                        // no break here 
    124145                    default: 
    125                         if (conf.reader_wrap_by_words) { 
     146                        if (*conf_reader_wrap_by_words) { 
    126147                            if (buffer[i] == ' ') { 
    127148                                new_word = 1; 
     
    153174                            continue; 
    154175                        } 
    155                         xx+=rbf_draw_char(xx, yy, buffer[i], conf.reader_color); 
     176                        xx+=rbf_draw_char(xx, yy, buffer[i], *conf_reader_color); 
    156177                        break; 
    157178                } 
     
    165186        } 
    166187     
    167         sprintf(buffer, "(%3d%%) %d/%d  ", (read_file_size)?(conf.reader_pos*100/read_file_size):0, conf.reader_pos, read_file_size); 
     188        sprintf(buffer, "(%3d%%) %d/%d  ", (read_file_size)?(*conf_reader_pos*100/read_file_size):0, *conf_reader_pos, read_file_size); 
    168189        buffer[screen_width/FONT_WIDTH]=0; 
    169190        draw_txt_string((CAM_TS_BUTTON_BORDER/FONT_WIDTH), 0, buffer, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline 
     
    174195            n=i*read_on_screen/read_file_size;           // bar height 
    175196            if (n<20) n=20; 
    176             i=(i-n)*conf.reader_pos/read_file_size;   // top pos 
     197            i=(i-n)**conf_reader_pos/read_file_size;   // top pos 
    177198            draw_filled_rect(x+w+6+2, y+1,   x+w+6+6, y+1+i,   MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 
    178199            draw_filled_rect(x+w+6+2, y+i+n, x+w+6+6, y+h-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 
     
    197218        case KEY_UP: 
    198219        case KEY_LEFT: 
    199             if (conf.reader_pos>0) { 
    200                 conf.reader_pos -= 45*15; 
    201                 if (conf.reader_pos<0) conf.reader_pos=0; 
     220            if (*conf_reader_pos>0) { 
     221                *conf_reader_pos -= 45*15; 
     222                if (*conf_reader_pos<0) *conf_reader_pos=0; 
    202223                read_to_draw = 1; 
    203224            } 
     
    208229        case KEY_RIGHT: 
    209230        case KEY_SHOOT_HALF: 
    210             if ((conf.reader_pos+read_on_screen)<read_file_size) { 
    211                 conf.reader_pos += read_on_screen; 
     231            if ((*conf_reader_pos+read_on_screen)<read_file_size) { 
     232                *conf_reader_pos += read_on_screen; 
    212233                read_to_draw = 1; 
    213234            } 
     
    221242            break; 
    222243        case KEY_MENU: 
    223             if (read_file >= 0) { 
     244                        gui_read_kbd_leave(); 
     245            break; 
     246    } 
     247} 
     248 
     249extern int module_idx; 
     250 
     251//------------------------------------------------------------------- 
     252// Menu button handled for text reader 
     253void gui_read_kbd_process_menu_btn() 
     254{ 
     255    gui_read_kbd_process(); 
     256    gui_default_kbd_process_menu_btn(); 
     257        module_async_unload(module_idx); 
     258} 
     259 
     260void gui_read_kbd_leave() 
     261{ 
     262        if ( !reader_is_active ) 
     263                return; 
     264 
     265    reader_is_active = 0; 
     266            if (!rbf_load(conf_menu_rbf_file)) 
     267                rbf_load_from_8x16(current_font); 
     268            rbf_set_codepage(FONT_CP_WIN); 
     269        if (read_file >= 0) { 
    224270                close(read_file); 
    225271                read_file=-1; 
    226             } 
    227             if (!rbf_load(conf.menu_rbf_file)) 
    228                 rbf_load_from_8x16(current_font); 
    229             rbf_set_codepage(FONT_CP_WIN); 
    230             break; 
    231     } 
    232 } 
    233  
    234 //------------------------------------------------------------------- 
     272    } 
     273} 
     274 
     275// =========  MODULE INIT ================= 
     276#include "module_load.h" 
     277int module_idx=-1; 
     278 
     279/***************** BEGIN OF AUXILARY PART ********************* 
     280  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     281 **************************************************************/ 
     282 
     283void* MODULE_EXPORT_LIST[] = { 
     284        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     285        /* 1 */ (void*)0 
     286                }; 
     287 
     288 
     289//--------------------------------------------------------- 
     290// PURPOSE:   Bind module symbols with chdk.  
     291//              Required function 
     292// PARAMETERS: pointer to chdk list of export 
     293// RETURN VALUE: 1 error, 0 ok 
     294//--------------------------------------------------------- 
     295int _module_loader( void** chdk_export_list ) 
     296{ 
     297  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     298     return 1; 
     299 
     300  tConfigVal configVal; 
     301  CONF_BIND_COLOR( 31, conf_reader_color          ); 
     302  CONF_BIND_STR( 38, conf_reader_file             ); 
     303  CONF_BIND_INT( 39, conf_reader_pos              ); 
     304  CONF_BIND_INT( 43, conf_reader_autoscroll       ); 
     305  CONF_BIND_INT( 44, conf_reader_autoscroll_delay ); 
     306  CONF_BIND_INT( 61, conf_reader_wrap_by_words    ); 
     307  CONF_BIND_STR( 66, conf_menu_rbf_file           ); 
     308 
     309  return 0; 
     310} 
     311 
     312 
     313 
     314//--------------------------------------------------------- 
     315// PURPOSE: Finalize module operations (close allocs, etc) 
     316// RETURN VALUE: 0-ok, 1-fail 
     317//--------------------------------------------------------- 
     318int _module_unloader() 
     319{ 
     320  // We should make "leave sequence" to restore font settings 
     321  gui_read_kbd_leave(); 
     322 
     323  GUI_MODE_READ.magicnum = 0;   //sanity clean to prevent accidentaly assign/restore guimode to unloaded module  
     324 
     325  return 0; 
     326} 
     327 
     328 
     329//--------------------------------------------------------- 
     330// PURPOSE: Default action for simple modules (direct run) 
     331// NOTE: Please comment this function if no default action and this library module 
     332//--------------------------------------------------------- 
     333int _module_run(int moduleidx, int argn, int* arguments) 
     334{ 
     335  module_idx=moduleidx; 
     336 
     337  if ( argn!=1 || arguments[0]==0) { 
     338        module_async_unload(moduleidx); 
     339    return 1; 
     340  } 
     341 
     342  char* fn=(char*)arguments[0]; 
     343  gui_read_init(fn); 
     344 
     345  return 0; 
     346} 
     347 
     348 
     349/******************** Module Information structure ******************/ 
     350 
     351struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     352                                                                        sizeof(struct ModuleInfo), 
     353 
     354                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     355                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     356                                                                        MODULEINFO_FLAG_SYSTEM,         // flag 
     357                                                                        (int32_t)"Text reader",         // Module name 
     358                                                                        1, 0,                                           // Module version 
     359                                                                        0 
     360                                                                 }; 
     361 
     362/*************** END OF AUXILARY PART *******************/ 
  • trunk/core/gui_read.h

    r515 r1505  
    77extern int gui_read_init(const char* file); 
    88extern void gui_read_kbd_process(); 
    9 extern void gui_read_draw(); 
     9extern void gui_read_draw(int enforce_redraw); 
     10extern void gui_read_kbd_leave(); 
    1011 
    1112//------------------------------------------------------------------- 
  • trunk/core/gui_reversi.c

    r1338 r1505  
    1010#include "gui_mbox.h" 
    1111#include "gui_reversi.h" 
     12 
     13#include "module_load.h" 
     14void gui_module_menu_kbd_process(); 
     15 
     16gui_handler GUI_MODE_REVERSI =  
     17    /*GUI_MODE_REVERSI*/        { gui_reversi_draw,     gui_reversi_kbd_process,    gui_module_menu_kbd_process, GUI_MODE_FLAG_NODRAWRESTORE, GUI_MODE_MAGICNUM }; 
     18 
    1219 
    1320//------------------------------------------------------------------- 
     
    344351 
    345352//------------------------------------------------------------------- 
    346 void gui_reversi_init() { 
     353int basic_module_init() { 
     354    gui_set_mode((unsigned int)&GUI_MODE_REVERSI); 
    347355    InitMainWindow(); 
    348356    NewGame(); 
    349357    need_redraw_all = 1; 
     358        return 1; 
    350359} 
    351360 
     
    376385            need_redraw = 1; 
    377386            break; 
    378       #if CAM_HAS_ERASE_BUTTON 
    379387        case KEY_ERASE: 
    380       #else 
    381388        case KEY_DISPLAY: 
    382       #endif 
    383389            if (InGame) 
    384390                Computer=COMPUTER_ONLY; 
     
    387393            need_redraw = 1; 
    388394            break; 
    389       #if CAM_HAS_ERASE_BUTTON 
    390         case KEY_DISPLAY: 
    391             gui_mbox_init(LANG_MBOX_ABOUT_TITLE, (int)"REVERSI\n(c) GrAnd, 2007", MBOX_TEXT_CENTER, NULL); 
    392             need_redraw_all = 1; 
    393             break; 
    394       #endif 
    395     } 
    396 } 
    397  
    398 //------------------------------------------------------------------- 
    399 void gui_reversi_draw() { 
     395    } 
     396} 
     397 
     398//------------------------------------------------------------------- 
     399void gui_reversi_draw(int enforce_redraw) { 
    400400    if (need_redraw_all) { 
    401401        need_redraw_all = 0; 
     
    415415} 
    416416 
     417 
     418extern int module_idx; 
     419void gui_module_menu_kbd_process() { 
     420        gui_default_kbd_process_menu_btn(); 
     421        module_async_unload(module_idx); 
     422} 
     423 
     424 
     425/******************** Module Information structure ******************/ 
     426 
     427struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     428                                                                        sizeof(struct ModuleInfo), 
     429 
     430                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     431                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     432                                                                        0,                                                      // flag 
     433                                                                        -LANG_MENU_GAMES_REVERSI,       // Module name 
     434                                                                        1, 0,                                           // Module version 
     435                                                                        (int32_t)"Game" 
     436                                                                 }; 
  • trunk/core/gui_reversi.h

    r515 r1505  
    55extern void gui_reversi_init(); 
    66extern void gui_reversi_kbd_process(); 
    7 extern void gui_reversi_draw(); 
     7extern void gui_reversi_draw(int enforce_redraw); 
    88 
    99//------------------------------------------------------------------- 
  • trunk/core/gui_snake.c

    r1467 r1505  
    320320              
    321321            break; 
    322       #if CAM_HAS_ERASE_BUTTON 
    323322        case KEY_ERASE: 
    324       #else 
    325323        case KEY_DISPLAY: 
    326       #endif 
    327324            break; 
    328325    } 
     
    447444 **************************************************************/ 
    448445 
    449 int _chdk_required_ver = 1;             // minimal required chdk build. 0-no limitation 
    450 int _chdk_required_platfid = 0;         // platform-specific module. 0-no limitation 
    451  
    452446void* MODULE_EXPORT_LIST[] = { 
    453447        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     
    497491} 
    498492 
     493/******************** Module Information structure ******************/ 
     494 
     495struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     496                                                                        sizeof(struct ModuleInfo), 
     497 
     498                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     499                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     500                                                                        0,                                                      // flag 
     501                                                                        (int32_t)"Snake",                       // Module name 
     502                                                                        1, 0,                                           // Module version 
     503                                                                        (int32_t)"Game" 
     504                                                                 }; 
     505 
    499506 
    500507/*************** END OF AUXILARY PART *******************/ 
  • trunk/core/gui_sokoban.c

    r1338 r1505  
    1111#include "gui_mbox.h" 
    1212#include "gui_sokoban.h" 
     13 
     14#include "module_load.h" 
     15void gui_module_menu_kbd_process(); 
     16 
     17int *conf_sokoban_level; 
     18 
     19gui_handler GUI_MODE_SOKOBAN =  
     20    /*GUI_MODE_SOKOBAN*/        { gui_sokoban_draw,     gui_sokoban_kbd_process,    gui_module_menu_kbd_process, GUI_MODE_FLAG_NODRAWRESTORE, GUI_MODE_MAGICNUM }; 
     21 
    1322 
    1423//------------------------------------------------------------------- 
     
    197206     
    198207    free(buf); 
    199     conf.sokoban_level = lvl; 
     208    *conf_sokoban_level = lvl; 
    200209    moves = 0; 
    201210    sokoban_undo_reset(); 
     
    215224//------------------------------------------------------------------- 
    216225static void sokoban_next_level() { 
    217     if (++conf.sokoban_level >= num_levels) conf.sokoban_level = 0; 
    218     sokoban_set_level(conf.sokoban_level); 
     226    if (++*conf_sokoban_level >= num_levels) *conf_sokoban_level = 0; 
     227    sokoban_set_level(*conf_sokoban_level); 
    219228    need_redraw_all = 1; 
    220229} 
     
    266275        char *buf,*p; 
    267276        FILE *fd;     
    268         struct stat st; 
    269  
    270         if (stat((char *)level_file_name,&st) != 0 || st.st_size==0)  
     277        struct STD_stat st; 
     278 
     279        if (safe_stat((char *)level_file_name,&st) != 0 || st.st_size==0)  
    271280            return 0; 
    272281 
     
    313322        return 0; 
    314323    } 
    315     else if(conf.sokoban_level >= num_levels) { 
    316         conf.sokoban_level = 0; 
     324    else if(*conf_sokoban_level >= num_levels) { 
     325        *conf_sokoban_level = 0; 
    317326    } 
    318327    cell_size = screen_height/FIELD_HEIGHT; 
    319     sokoban_set_level(conf.sokoban_level); 
     328    sokoban_set_level(*conf_sokoban_level); 
    320329        // if the file is no longer readable, set_level will set this 
    321330    if(!num_levels) { 
     
    323332    } 
    324333    need_redraw_all = 1; 
     334 
     335    gui_set_mode((unsigned int)&GUI_MODE_SOKOBAN); 
    325336    return 1; 
    326337} 
     
    358369            need_redraw = 1; 
    359370            break; 
    360       #if CAM_HAS_ERASE_BUTTON 
    361371        case KEY_ERASE: 
    362       #else 
    363372        case KEY_DISPLAY: 
    364       #endif 
    365             sokoban_set_level(conf.sokoban_level); 
     373            sokoban_set_level(*conf_sokoban_level); 
    366374            need_redraw_all = 1; 
    367375            break; 
    368       #if CAM_HAS_ERASE_BUTTON 
    369         case KEY_DISPLAY: 
    370             gui_mbox_init(LANG_MBOX_ABOUT_TITLE, (int)"SOKOBAN\n(c) GrAnd, 2007", MBOX_TEXT_CENTER, NULL); 
    371             need_redraw = 1; 
    372             break; 
    373      #endif 
    374     } 
    375 } 
    376  
    377 //------------------------------------------------------------------- 
    378 void gui_sokoban_draw() { 
     376    } 
     377} 
     378 
     379//------------------------------------------------------------------- 
     380void gui_sokoban_draw(int enforce_redraw) { 
    379381    int y, x; 
    380382    static char str[16]; 
     
    420422        draw_line(CAM_TS_BUTTON_BORDER+cell_size*FIELD_WIDTH+1, 0, CAM_TS_BUTTON_BORDER+cell_size*FIELD_WIDTH+1, screen_height-1, COLOR_BLACK); 
    421423 
    422         sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_LEVEL), conf.sokoban_level+1); 
     424        sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_LEVEL), *conf_sokoban_level+1); 
    423425        draw_string(CAM_TS_BUTTON_BORDER+cell_size*FIELD_WIDTH+2, 8, str, MAKE_COLOR(SCREEN_COLOR, COLOR_WHITE)); 
    424426        sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_MOVES), moves); 
     
    437439} 
    438440 
     441 
     442extern int module_idx; 
     443void gui_module_menu_kbd_process() { 
     444        gui_default_kbd_process_menu_btn(); 
     445        module_async_unload(module_idx); 
     446} 
     447 
     448 
     449// =========  MODULE INIT ================= 
     450#include "module_load.h" 
     451int module_idx=-1; 
     452 
     453/***************** BEGIN OF AUXILARY PART ********************* 
     454  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     455 **************************************************************/ 
     456 
     457void* MODULE_EXPORT_LIST[] = { 
     458        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     459        /* 1 */ (void*)0 
     460                }; 
     461 
     462 
     463//--------------------------------------------------------- 
     464// PURPOSE:   Bind module symbols with chdk.  
     465//              Required function 
     466// PARAMETERS: pointer to chdk list of export 
     467// RETURN VALUE: 1 error, 0 ok 
     468//--------------------------------------------------------- 
     469int _module_loader( void** chdk_export_list ) 
     470{ 
     471  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     472     return 1; 
     473 
     474  // Safe bind of conf. 
     475  tConfigVal configVal; 
     476  CONF_BIND_INT(40, conf_sokoban_level ); 
     477 
     478  return 0; 
     479} 
     480 
     481 
     482 
     483//--------------------------------------------------------- 
     484// PURPOSE: Finalize module operations (close allocs, etc) 
     485// RETURN VALUE: 0-ok, 1-fail 
     486//--------------------------------------------------------- 
     487int _module_unloader() 
     488{ 
     489  return 0; 
     490} 
     491 
     492 
     493//--------------------------------------------------------- 
     494// PURPOSE: Default action for simple modules (direct run) 
     495// NOTE: Please comment this function if no default action and this library module 
     496//--------------------------------------------------------- 
     497int _module_run(int moduleidx, int argn, int* arguments) 
     498{ 
     499  module_idx=moduleidx; 
     500 
     501  int rv = gui_sokoban_init(); 
     502  if ( ! rv ) 
     503        module_async_unload(moduleidx);         // fail to init - "unload me" 
     504 
     505  return 0; 
     506} 
     507 
     508 
     509/******************** Module Information structure ******************/ 
     510 
     511struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     512                                                                        sizeof(struct ModuleInfo), 
     513 
     514                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     515                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     516                                                                        0,                                                      // flag 
     517                                                                        -LANG_MENU_GAMES_SOKOBAN,       // Module name 
     518                                                                        1, 0,                                           // Module version 
     519                                                                        (int32_t)"Game" 
     520                                                                 }; 
     521 
     522/*************** END OF AUXILARY PART *******************/ 
  • trunk/core/gui_sokoban.h

    r522 r1505  
    55extern int gui_sokoban_init(); 
    66extern void gui_sokoban_kbd_process(); 
    7 extern void gui_sokoban_draw(); 
     7extern void gui_sokoban_draw(int enforce_redraw); 
    88 
    99//------------------------------------------------------------------- 
  • trunk/core/gui_tetris.c

    r1467 r1505  
    121121{ 
    122122    // Check if directory exists and create it if it does not. 
    123     struct stat st; 
    124     if (stat(dirname,&st) != 0) return mkdir(dirname); 
     123    struct STD_stat st; 
     124    if (safe_stat(dirname,&st) != 0) return mkdir(dirname); 
    125125    return 0;   // Success 
    126126} 
     
    738738 **************************************************************/ 
    739739 
    740 int _chdk_required_ver = 1;             // minimal required chdk build. 0-no limitation 
    741 int _chdk_required_platfid = 0;         // platform-specific module. 0-no limitation 
    742  
    743740void* MODULE_EXPORT_LIST[] = { 
    744741        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     
    793790 
    794791 
     792/******************** Module Information structure ******************/ 
     793 
     794struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     795                                                                        sizeof(struct ModuleInfo), 
     796 
     797                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     798                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     799                                                                        0,                                                      // flag 
     800                                                                        (int32_t)"Tetris",                      // Module name 
     801                                                                        1, 0,                                           // Module version 
     802                                                                        (int32_t)"Game" 
     803                                                                 }; 
     804 
    795805/*************** END OF AUXILARY PART *******************/ 
  • trunk/core/kbd.c

    r1464 r1505  
    1212#include "lang.h" 
    1313#include "gui_lang.h" 
     14 
     15#include "module_load.h" 
     16#include "gui.h" 
    1417 
    1518long kbd_last_clicked; 
     
    171174    unsigned int nCrzpos,i; 
    172175    unsigned int drmode = 0; 
     176 
     177#if defined(CAMERA_s95) 
     178                extern volatile int kbd_KEY_RING_FUNC; 
     179            if (kbd_KEY_RING_FUNC && gui_get_mode()!=GUI_MODE_NONE) { 
     180                        if (module_find("modinsp.flt")<0) 
     181                          module_run("modinsp.flt", 0, 0,0, UNLOAD_IF_ERR); 
     182                } 
     183#endif 
     184 
    173185 
    174186    if(conf.ricoh_ca1_mode && conf.remote_enable) { 
  • trunk/core/luascript.c

    r1479 r1505  
    1010#include "stdlib.h" 
    1111#include "raw.h" 
    12 #include "raw_merge.h" 
     12#include "modules.h" 
    1313#include "levent.h" 
    1414#include "console.h" 
     
    127127void lua_script_reset() 
    128128{ 
     129  module_rawop_unload(); 
    129130  lua_close( L ); 
    130131  L = 0; 
     
    268269  int value; 
    269270  value=luaL_checknumber( L, 1 ); 
     271  if (module_curves_load()) 
     272    return luaL_argerror(L,1,"fail to load curves module"); 
    270273  curve_set_mode(value); 
    271274  return 0; 
     
    818821    // the Func/Set key again will enter the Script menu, not the File Browser 
    819822    kbd_reset_autoclicked_key(); 
     823 
     824        lua_pushstring( Lt, (fn && fn[0])? fn : NULL ); 
     825 
    820826} 
    821827 
     
    826832    action_push(AS_FILE_BROWSER); 
    827833    // Switch to file browser gui mode. Path can be supplied in call or defaults to "A" (root directory). 
    828     gui_fselect_init(LANG_STR_FILE_BROWSER, luaL_optstring( L, 1, "A" ), "A", file_browser_selected); 
     834    module_fselect_init(LANG_STR_FILE_BROWSER, luaL_optstring( L, 1, "A" ), "A", file_browser_selected); 
    829835    // Yield the script so that the action stack will process the AS_FILE_BROWSER action 
    830836    return lua_yield(L, 0); 
     
    13811387{ 
    13821388  int op = luaL_checknumber(L,1); 
     1389  if (!module_rawop_load()) 
     1390    return luaL_argerror(L,1,"fail to load raw merge module"); 
    13831391  if (op == RAW_OPERATION_SUM || op == RAW_OPERATION_AVERAGE) { 
    1384     raw_merge_start(op); 
     1392    librawop.raw_merge_start(op); 
    13851393  } 
    13861394  else { 
     
    13931401static int luaCB_raw_merge_add_file( lua_State* L ) 
    13941402{ 
    1395   raw_merge_add_file(luaL_checkstring( L, 1 )); 
     1403  if (!module_rawop_load()) 
     1404    return luaL_argerror(L,1,"fail to load raw merge module"); 
     1405  librawop.raw_merge_add_file(luaL_checkstring( L, 1 )); 
    13961406  return 0; 
    13971407} 
     
    13991409static int luaCB_raw_merge_end( lua_State* L ) 
    14001410{ 
    1401   raw_merge_end(); 
     1411  if (!module_rawop_load()) 
     1412    return luaL_argerror(L,1,"fail to load raw merge module"); 
     1413  librawop.raw_merge_end(); 
    14021414  return 0; 
    14031415} 
  • trunk/core/main.c

    r1484 r1505  
    88#include "raw.h" 
    99#ifdef OPT_EDGEOVERLAY 
    10     #include "edgeoverlay.h" 
    11 #endif 
     10    #include "modules.h" 
     11#endif 
     12 
     13#include "module_load.h" 
     14#include "gui_draw.h" 
     15 
    1216static int raw_need_postprocess; 
    1317static volatile int spytask_can_start; 
     
    142146    mkdir("A/CHDK/LANG"); 
    143147    mkdir("A/CHDK/BOOKS"); 
     148    mkdir("A/CHDK/MODULES"); 
    144149    mkdir("A/CHDK/GRIDS"); 
    145150#ifdef OPT_CURVES 
     
    184189        {        
    185190            histogram_process(); 
     191 
     192 
    186193#ifdef OPT_EDGEOVERLAY 
    187             if(conf.edge_overlay_thresh && conf.edge_overlay_enable) edge_overlay(); 
     194            if(conf.edge_overlay_thresh && conf.edge_overlay_enable) { 
     195 
     196                                // We need to skip first tick because stability 
     197                                static int skip_counter=1; 
     198                                 
     199                                if (skip_counter>0) { 
     200                                        skip_counter--; 
     201                                } 
     202                                else if (module_edgeovr_load()) { 
     203                                        edge_overlay(); 
     204                                } 
     205                        } 
    188206#endif 
    189207        } 
     
    199217                draw_txt_string(2, 2, osd_buf, conf.osd_color); 
    200218#endif   
     219 
     220                // Process async module unload requests 
     221                module_tick_unloader(); 
     222 
    201223        msleep(20); 
    202224    } 
  • trunk/core/module_exportlist.c

    r1467 r1505  
    22 *   THIS FILE IS FOR DECLARATION/LISTING OF EXPORTED TO MODULES SYMBOLS 
    33 * 
    4  *    CHDK-FLAT Module System.  Sergey Taranenko(@tsv) 
     4 *    CHDK-FLAT Module System.  Sergey Taranenko aka tsvstar 
    55 */ 
    66 
     
    99#include "platform.h" 
    1010#include "stdlib.h" 
     11#include "stdlib_unified.h" 
    1112#include "keyboard.h" 
    1213 
     
    1415#include "gui_draw.h" 
    1516#include "gui_batt.h" 
     17#include "gui_menu.h" 
    1618#include "gui_osd.h" 
     19#include "gui_mbox.h" 
     20#include "gui_mpopup.h" 
    1721#include "conf.h" 
    18 #include "gui_mbox.h" 
    1922#include "raw.h" 
    20 #include "gui_mpopup.h" 
    2123#include "bitvector.h" 
    2224#include "font.h" 
    2325 
    2426#include "modules.h" 
     27#include "module_load.h" 
    2528#include "raw.h" 
    26 #include "dng.h" 
    2729 
    2830 
     
    5355int RAW_CHDK_ROWLEN      = RAW_ROWLEN     ; 
    5456 
     57 
     58char SCREEN__EXPORTEDSYM_COLOR        = SCREEN_COLOR            ; 
     59char COLOR__EXPORTEDSYM_WHITE         = COLOR_WHITE         ; 
     60char COLOR__EXPORTEDSYM_RED           = COLOR_RED           ; 
     61char COLOR__EXPORTEDSYM_GREY          = COLOR_GREY          ; 
     62char COLOR__EXPORTEDSYM_GREEN         = COLOR_GREEN         ; 
     63char COLOR__EXPORTEDSYM_BLUE_LT       = COLOR_BLUE_LT       ; 
     64char COLOR__EXPORTEDSYM_BLUE          = COLOR_BLUE          ; 
     65char COLOR__EXPORTEDSYM_YELLOW        = COLOR_YELLOW        ; 
     66char COLOR__EXPORTEDSYM_BG            = COLOR_BG            ; 
     67char COLOR__EXPORTEDSYM_FG            = COLOR_FG            ; 
     68char COLOR__EXPORTEDSYM_SELECTED_BG   = COLOR_SELECTED_BG   ; 
     69char COLOR__EXPORTEDSYM_SELECTED_FG   = COLOR_SELECTED_FG   ; 
     70char COLOR__EXPORTEDSYM_ALT_BG        = COLOR_ALT_BG        ; 
     71char COLOR__EXPORTEDSYM_SPLASH_RED    = COLOR_SPLASH_RED    ; 
     72char COLOR__EXPORTEDSYM_SPLASH_PINK   = COLOR_SPLASH_PINK   ; 
     73char COLOR__EXPORTEDSYM_SPLASH_GREY   = COLOR_SPLASH_GREY   ; 
     74char COLOR__EXPORTEDSYM_HISTO_R       = COLOR_HISTO_R       ; 
     75char COLOR__EXPORTEDSYM_HISTO_R_PLAY  = COLOR_HISTO_R_PLAY  ; 
     76char COLOR__EXPORTEDSYM_HISTO_B       = COLOR_HISTO_B       ; 
     77char COLOR__EXPORTEDSYM_HISTO_G       = COLOR_HISTO_G       ; 
     78char COLOR__EXPORTEDSYM_HISTO_G_PLAY  = COLOR_HISTO_G_PLAY  ; 
     79char COLOR__EXPORTEDSYM_HISTO_BG      = COLOR_HISTO_BG      ; 
     80char COLOR__EXPORTEDSYM_HISTO_RG      = COLOR_HISTO_RG      ; 
     81char COLOR__EXPORTEDSYM_HISTO_RB      = COLOR_HISTO_RB      ; 
     82char COLOR__EXPORTEDSYM_HISTO_RB_PLAY = COLOR_HISTO_RB_PLAY ; 
     83char COLOR__EXPORTEDSYM_HISTO_B_PLAY  = COLOR_HISTO_B_PLAY  ; 
     84char COLOR__EXPORTEDSYM_HISTO_BG_PLAY = COLOR_HISTO_BG_PLAY ; 
     85char COLOR__EXPORTEDSYM_HISTO_RG_PLAY = COLOR_HISTO_RG_PLAY ; 
     86 
     87short EDGE__EXPORTEDSYM_HMARGIN = EDGE_HMARGIN; 
     88short CAM__EXPORTEDSYM_TS_BUTTON_BORDER = CAM_TS_BUTTON_BORDER; 
     89 
     90 
    5591/* EXPORTED_DEFINES_END */ 
    5692 
     
    5894//    1. DO NOT CHANGE ORDER AND DO NOT DELETE EXISTED ENTRIES 
    5995//    2. VARIABLE conf SHOULDN'T EXIST IN THE LIST TO KEEP ISOLATION. USE set|get_chdk_conf|get_chdk_conf_ptr INSTEAD 
     96//      STOPLIST: conf, open, opendir, closedir, rewinddir, readdir, stat 
    6097 
    6198void* CHDK_EXPORT_LIST[] = { 
     
    71108            umalloc, 
    72109            ufree, 
    73             open, 
     110            safe_open, 
    74111            write, 
    75112            lseek, 
     
    83120            fread, 
    84121            fwrite, 
    85             stat, 
    86             opendir, 
    87             readdir, 
    88             closedir, 
     122            safe_stat, 
     123            safe_opendir, 
     124            safe_readdir, 
     125            safe_closedir, 
    89126 
    90127            get_tick_count, 
     
    144181                // for edgeovr.flt 
    145182                        vid_get_viewport_width, 
    146                         vid_get_viewport_buffer_width, 
     183            vid_get_viewport_byte_width, 
    147184            vid_get_viewport_xoffset, 
    148185            vid_get_viewport_yoffset, 
     186            vid_get_viewport_yscale, 
    149187            vid_get_viewport_fb_d, 
    150188            kbd_is_key_pressed, 
     
    192230                        msleep, 
    193231            GetTotalCardSpaceKb, 
    194                         convert_dng_to_chdk_raw, 
     232                        module_convert_dng_to_chdk_raw, 
    195233                        raw_prepare_develop, 
    196234 
     
    209247                        mkdir, 
    210248 
     249                        gui_bind_mode, 
     250 
     251                        // modlist.flt 
     252                        load_from_file, 
     253                        rbf_draw_string_len, 
     254                        rbf_draw_menu_header, 
     255                        gui_force_restore, 
     256 
     257                        // modmenu.flt 
     258                        gui_menu_run_fltmodule, 
     259 
     260                        // export palette 
     261                        &SCREEN__EXPORTEDSYM_COLOR               , 
     262                        &COLOR__EXPORTEDSYM_WHITE        , 
     263                        &COLOR__EXPORTEDSYM_RED          , 
     264                        &COLOR__EXPORTEDSYM_GREY         , 
     265                        &COLOR__EXPORTEDSYM_GREEN        , 
     266                        &COLOR__EXPORTEDSYM_BLUE_LT      , 
     267                        &COLOR__EXPORTEDSYM_BLUE         , 
     268                        &COLOR__EXPORTEDSYM_YELLOW       , 
     269                        &COLOR__EXPORTEDSYM_BG           , 
     270                        &COLOR__EXPORTEDSYM_FG           , 
     271                        &COLOR__EXPORTEDSYM_SELECTED_BG  , 
     272                        &COLOR__EXPORTEDSYM_SELECTED_FG  , 
     273                        &COLOR__EXPORTEDSYM_ALT_BG       , 
     274                        &COLOR__EXPORTEDSYM_SPLASH_RED   , 
     275                        &COLOR__EXPORTEDSYM_SPLASH_PINK  , 
     276                        &COLOR__EXPORTEDSYM_SPLASH_GREY  , 
     277                        &COLOR__EXPORTEDSYM_HISTO_R      , 
     278                        &COLOR__EXPORTEDSYM_HISTO_R_PLAY , 
     279                        &COLOR__EXPORTEDSYM_HISTO_B      , 
     280                        &COLOR__EXPORTEDSYM_HISTO_G      , 
     281                        &COLOR__EXPORTEDSYM_HISTO_G_PLAY , 
     282                        &COLOR__EXPORTEDSYM_HISTO_BG     , 
     283                        &COLOR__EXPORTEDSYM_HISTO_RG     , 
     284                        &COLOR__EXPORTEDSYM_HISTO_RB     , 
     285                        &COLOR__EXPORTEDSYM_HISTO_RB_PLAY, 
     286                        &COLOR__EXPORTEDSYM_HISTO_B_PLAY , 
     287                        &COLOR__EXPORTEDSYM_HISTO_BG_PLAY, 
     288                        &COLOR__EXPORTEDSYM_HISTO_RG_PLAY, 
     289 
     290                        // some common required sym 
     291                        &EDGE__EXPORTEDSYM_HMARGIN, 
     292                        &CAM__EXPORTEDSYM_TS_BUTTON_BORDER, 
     293 
     294                        // profile.flt 
     295                        find_mnu, 
     296                        lang_strhash31, 
     297 
    211298                        0 
    212299}; 
    213  
    214 /*                      debug_open, 
    215                         debug_print_int, 
    216                         debug_print, 
    217                         debug_flush, 
    218                         debug_close, 
    219 */ 
    220  
  • trunk/core/module_load.c

    r1467 r1505  
    22 *   CHDK-FLAT Module System.   
    33 * 
    4  *   (c)2011 Sergey Taranenko aka @tsv  
     4 *   (c)2011 Sergey Taranenko aka tsvstar 
    55 * 
    66 *   This is main file of module processing system. Module load/unload/service functions 
     
    1010#include "console.h" 
    1111#include "gui.h" 
     12#include "platform.h" 
    1213 
    1314#include "flt.h" 
     
    2021//********************************************************/ 
    2122 
    22 #include "module_exportlist.c" 
    23  
     23extern void* CHDK_EXPORT_LIST[]; 
    2424 
    2525#define MAX_NUM_LOADED_MODULES 10 
     
    109109                strcpy(tgt,name); 
    110110        else 
    111    sprintf(tgt,"A/CHDK/MODULES/%s",name); 
     111   sprintf(tgt,"%s/%s",MODULES_PATH,name); 
    112112} 
    113113 
     
    169169                ptr = (uint32_t*)(buf+*relocbuf); 
    170170          //@tsv todo: if (*relocbuf>=flat->reloc_start) error_out_of_bound 
     171                // No such symbol to import 
    171172                if ( *ptr<2 || *ptr>EXPORTLIST_LAST_IDX ) 
    172173                        return 0; 
    173174 
    174                 *ptr = /*0xFFFFFFFE &*/ (uint32_t) CHDK_EXPORT_LIST[*ptr]; 
     175                *ptr = (uint32_t) CHDK_EXPORT_LIST[*ptr]; 
     176                // Empty symbol - module could only if import such symbol manually 
     177                if ( *ptr==0 ) 
     178                        return 0; 
    175179                relocbuf++; 
    176180        }   
     
    293297   if  ( flat.rev!=FLAT_VERSION || memcmp( flat.magic, FLAT_MAGIC_NUMBER, 4) ) 
    294298      return moduleload_error("bad magicnum", 0); 
    295  
    296    if  ( flat.chdk_min_version > CHDK_BUILD_NUM ) 
    297       return moduleload_error("require CHDK%d", flat.chdk_min_version); 
    298  
    299    if  ( flat.chdk_req_platfid && flat.chdk_req_platfid != PLATFORMID ) 
    300       return moduleload_error("require platfid %d", flat.chdk_req_platfid); 
    301299 
    302300   size_flat = flat.bss_end+1; 
     
    313311   b_close(-1); // filebuf not needed below 
    314312 
     313 
     314   // Module info checks 
     315 
     316   struct ModuleInfo* _module_info = 0; 
     317   if ( flat._module_info )     
     318   {  
     319         _module_info = (struct ModuleInfo* ) ((unsigned int)flat_buf+flat._module_info); 
     320 
     321         if  ( _module_info->magicnum != MODULEINFO_V1_MAGICNUM || 
     322                   _module_info->sizeof_struct != sizeof(struct ModuleInfo) ) 
     323       return moduleload_error("Malformed module info", 0 ); 
     324 
     325         if  ( _module_info->chdk_required_branch && 
     326                   _module_info->chdk_required_branch != CURRENT_CHDK_BRANCH ) 
     327       return moduleload_error("require different CHDK branch",0 ); 
     328 
     329         if  ( _module_info->chdk_required_ver > CHDK_BUILD_NUM) 
     330       return moduleload_error("require CHDK%05d", _module_info->chdk_required_ver); 
     331 
     332     if  ( _module_info->chdk_required_platfid &&  
     333                   _module_info->chdk_required_platfid != PLATFORMID ) 
     334       return moduleload_error("require platfid %d", _module_info->chdk_required_platfid); 
     335   } 
     336 
     337   // Make relocations 
     338 
    315339   if ( !module_do_action( "reloc", flat.reloc_start, flat.reloc_count, module_do_relocations ) ) 
    316340          return -1; 
     
    321345   module_fd = -1; 
    322346 
     347   // Module is valid. Finalize binding 
     348 
    323349   modules[idx] = (struct flat_hdr* )flat_buf; 
    324350 
     351   modules[idx]->_module_info = (uint32_t) _module_info; 
    325352   if ( flat._module_loader )    { modules[idx]->_module_loader += (unsigned int)flat_buf; } 
    326353   if ( flat._module_unloader )  { modules[idx]->_module_unloader += (unsigned int)flat_buf; } 
    327354   if ( flat._module_run )       { modules[idx]->_module_run += (unsigned int)flat_buf; } 
    328355 
    329  
    330356   // store runtime params 
    331357   flat_module_name_make(modules[idx]->modulename, name); 
    332    modules[idx]->runtime_bind_callback = callback;     //@tsv reuse unneeded entry to store valuable 
     358   modules[idx]->runtime_bind_callback = (uint32_t) callback;     //@tsv reuse unneeded entry to store valuable 
    333359 
    334360   int bind_err=0; 
  • trunk/core/module_load.h

    r1467 r1505  
    44#include "gui.h" 
    55#include "gui_draw.h" 
     6#include "flt.h" 
     7#ifndef THIS_IS_CHDK_CORE 
     8#include "module_exportlist.h" 
     9#endif 
     10 
     11// This is main CHDK trunk 
     12#define CURRENT_CHDK_BRANCH 1 
     13 
     14#define MODULES_PATH "A/CHDK/MODULES" 
     15 
     16 
     17// Base typedefs 
     18//------------------- 
    619 
    720#define EXPORTLIST_MAGIC_NUMBER  0x43215678 
     
    1831}; 
    1932 
     33 
     34// Common module functions 
     35//------------------------- 
     36 
    2037int module_check_is_exist(char* name); 
    2138int module_find(char * name ); 
     
    2845void module_set_flags(unsigned int idx, char value); 
    2946 
     47void* module_get_adr(unsigned int idx); 
     48 
     49 
     50// Asynchronous unloading 
     51//------------------------- 
    3052void module_async_unload(unsigned int idx); 
    3153void module_async_unload_allrunned(int enforce); 
    3254void module_tick_unloader(); 
    3355 
    34 void* module_get_adr(unsigned int idx); 
    35  
    36  
     56// In-module binding to conf. 
     57//--------------------------- 
    3758#define CONF_BIND_INT(idConf,var)  if ( conf_getValue(idConf, &configVal) == CONF_VALUE ) {     var = configVal.pInt; } else { return 1;} 
    3859#define CONF_BIND_COLOR(idConf,var)  if ( conf_getValue(idConf, &configVal) == CONF_VALUE ) {   var = (color*)configVal.pInt; } else { return 1;} 
  • trunk/core/module_wrappers.c

    r1495 r1505  
    1616{ 
    1717        int real_flags = flags & ~(STD_O_TRUNC|STD_O_CREAT); 
    18         if ( flags & STD_O_TRUNC ) real_flags = O_TRUNC; 
    19         if ( flags & STD_O_CREAT ) real_flags = O_CREAT; 
     18        if ( flags & STD_O_TRUNC ) real_flags |= O_TRUNC; 
     19        if ( flags & STD_O_CREAT ) real_flags |= O_CREAT; 
    2020        return open( name, real_flags, mode); 
    2121} 
     
    9595        memset( &(dir->de), 0, sizeof(dir->de)); 
    9696#else 
     97        dir->de.unk1 = de->unk1; 
    9798        dir->de.attrib = de->attrib; 
    9899        dir->de.size  = de->size; 
  • trunk/core/modules.c

    r1467 r1505  
    22 *   CHDK-FLAT Module System.   
    33 * 
    4  *   (c)2011 Sergey Taranenko aka @tsv  
     4 *   (c)2011 Sergey Taranenko aka tsvstar 
    55 * 
    66 *   Specific "shortcuts", dynamic libraries binding 
     
    1313#include "conf.h" 
    1414#include "gui_draw.h" 
     15#include "dng.h" 
    1516 
    1617/************* DYNAMIC LIBRARY RAWOPERATION ******/ 
     
    242243} 
    243244 
    244  
     245/************* OTHER MODULES ******/ 
     246 
     247void module_convert_dng_to_chdk_raw(char* fn) 
     248{ 
     249#if DNG_SUPPORT 
     250        convert_dng_to_chdk_raw(fn); 
     251#endif 
     252} 
  • trunk/core/modules.h

    r1467 r1505  
    3838 
    3939 
     40 
     41//-------------------------- 
     42void module_convert_dng_to_chdk_raw(char* fn); 
     43 
     44 
    4045#endif 
  • trunk/core/modules/Makefile

    r1467 r1505  
    1515LDLIBS= -lgcc 
    1616LDOPTS=-nostdlib -Wl,--allow-shlib-undefined -Wl,-T,$(topdir)tools/link-boot.ld 
    17 LDOPTS+=-Wl,-N,-Ttext,$(MEMISOSTART) -r -d 
     17LDOPTS+=-Wl,-N,-Ttext,0x0016ee30 -r -Wl,-d 
    1818 
    1919OBJS=../gui_calendar.o ../gui_bench.o ../gui_4wins.o ../gui_mastermind.o ../gui_reversi.o \ 
    20          ../gui_sokoban.o ../gui_read.o ../edgeoverlay.o ../gui_debug.o ../gui_palette.o \ 
    21          ../curves.o ../gui_fselect.o ../nothumb.o ../gui_mpopup.o ../gui_tetris.o ../gui_snake.o 
     20         ../gui_sokoban.o ../gui_read.o ../gui_debug.o  ../gui_tetris.o ../gui_snake.o 
     21 
     22 
     23CFLAGS+=-DOPT_GENERIC_MODULES 
     24OPT_OBJS= ../gui_fselect.o ../nothumb.o ../gui_mpopup.o ../curves.o ../edgeoverlay.o ../gui_palette.o 
     25OPT_FLT= fselect.flt edgeovr.flt curves.flt mpopup.flt palette.flt 
    2226 
    2327 
    2428all: exportlist ../flt.h \ 
    2529                benchm.flt calend.flt 4wins.flt mastmind.flt reversi.flt sokoban.flt _rawop10.flt _rawop12.flt \ 
    26                 edgeovr.flt txtread.flt memview.flt palette.flt modinsp.flt curves.flt fselect.flt mpopup.flt \ 
    27                 tetris.flt snake.flt 
     30                txtread.flt memview.flt modinsp.flt tetris.flt snake.flt modmenu.flt $(OPT_FLT) 
    2831 
    2932%.o: %.c 
     
    4447calend.elf: simple_module.o ../gui_calendar.o 
    4548        @echo \-\> $@ 
    46         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     49        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    4750 
    4851benchm.elf: simple_module.o ../gui_bench.o 
    4952        @echo \-\> $@ 
    50         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     53        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    5154 
    52 4wins.elf: simple_module.o ../gui_4wins.o 
     554wins.elf: simple_game.o ../gui_4wins.o 
    5356        @echo \-\> $@ 
    54         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     57        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    5558 
    56 mastmind.elf: simple_module.o ../gui_mastermind.o 
     59mastmind.elf: simple_game.o ../gui_mastermind.o 
    5760        @echo \-\> $@ 
    58         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     61        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    5962 
    60 reversi.elf: simple_module.o ../gui_reversi.o 
     63reversi.elf: simple_game.o ../gui_reversi.o 
    6164        @echo \-\> $@ 
    62         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     65        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    6366 
    6467tetris.elf: ../gui_tetris.o 
    6568        @echo \-\> $@ 
    66         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     69        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    6770 
    6871snake.elf: ../gui_snake.o 
    6972        @echo \-\> $@ 
    70         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     73        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    7174 
    7275sokoban.elf: ../gui_sokoban.o 
    7376        @echo \-\> $@ 
    74         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     77        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    7578 
    7679memview.elf:  ../gui_debug.o 
    7780        @echo \-\> $@ 
    78         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     81        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    7982 
    8083palette.elf:  ../gui_palette.o 
    8184        @echo \-\> $@ 
    82         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     85        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    8386 
    8487mpopup.elf:  ../gui_mpopup.o 
    8588        @echo \-\> $@ 
    86         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     89        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    8790 
    8891txtread.elf: ../gui_read.o 
    8992        @echo \-\> $@ 
    90         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     93        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    9194 
    9295edgeovr.elf: ../edgeoverlay.o $(OBJ_ISDIGIT) 
    9396        @echo \-\> $@ 
    94         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     97        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    9598 
    9699curves.elf: ../curves.o 
    97100        @echo \-\> $@ 
    98         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     101        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    99102 
    100103modinsp.elf: module_inspector.o 
    101104        @echo \-\> $@ 
    102         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     105        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
     106 
     107modmenu.elf: module_menu.o ../nothumb.o 
     108        @echo \-\> $@ 
     109        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    103110 
    104111_rawop10.elf: raw_merge10.o 
    105112        @echo \-\> $@ 
    106         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     113        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    107114 
    108115_rawop12.elf: raw_merge12.o 
    109116        @echo \-\> $@ 
    110         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     117        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    111118 
    112119raw_merge10.o: ../raw_merge.c 
     
    120127#lua.elf: lib_edgeoverlay.o ../luascript.o $(topdir)lib/lua/liblua.a 
    121128#       @echo \-\> $@ 
    122 #       $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     129#       $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    123130 
    124131fselect.elf: ../gui_fselect.o ../nothumb.o 
    125132        @echo \-\> $@ 
    126         $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 
     133        $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 
    127134 
    128135../nothumb.o: ../nothumb.c 
     
    131138 
    132139clean: 
    133         rm -f *.o *.elf.syms *.elf $(OBJS) 
     140        rm -f *.o *.elf.syms *.elf *.flt $(OBJS) $(OPT_OBJS) 
    134141 
    135142distclean: clean 
  • trunk/core/modules/module_inspector.c

    r1467 r1505  
    99 
    1010extern int basic_module_init(); 
    11 void* _getmeminfo=0; 
     11void (*_getmeminfo)(void*) = 0; 
    1212 
    1313/***************** BEGIN OF AUXILARY PART ********************* 
    1414  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
    1515 **************************************************************/ 
    16  
    17 int _chdk_required_ver = 0;                     // minimal required chdk build. 0-no limitation 
    18 int _chdk_required_platfid = 0;         // platform-specific module. 0-no limitation 
    1916 
    2017void* MODULE_EXPORT_LIST[] = { 
     
    6360  return 0; 
    6461} 
     62 
     63/******************** Module Information structure ******************/ 
     64 
     65struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     66                                                                        sizeof(struct ModuleInfo), 
     67 
     68                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     69                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     70                                                                        0,                                                      // flag 
     71                                                                        (int32_t)"Module Inspector",// Module name 
     72                                                                        1, 0,                                           // Module version 
     73                                                                        (int32_t)"Show list of loaded modules" 
     74                                                                 }; 
    6575 
    6676 
     
    165175                if (_getmeminfo) { 
    166176 
    167                         extern void GetMemInfo(cam_meminfo*); 
    168  
    169177                cam_meminfo meminfo; 
    170178                        memset(&meminfo,sizeof(meminfo),0); 
    171                 GetMemInfo(&meminfo); 
     179                _getmeminfo(&meminfo); 
    172180 
    173181                        char txt[50]; 
  • trunk/core/modules/module_menu.c

    r1489 r1505  
    122122CMenu* scan_directory(const char* dir) { 
    123123 
    124     DIR           *d; 
    125     struct dirent *de; 
    126     static struct stat   st; 
     124    STD_DIR           *d; 
     125    struct STD_dirent *de; 
     126    static struct STD_stat   st; 
    127127 
    128128        char curdir[100]; 
     
    139139        for ( iter=1; iter<=2; iter++ ) 
    140140        { 
    141             d = opendir(curdir); 
     141            d = safe_opendir(curdir); 
    142142        if (!d) return 0; 
    143143 
    144144                count = 0; 
    145             for( de = readdir(d); de; de = readdir(d) ) { 
     145            for( de = safe_readdir(d); de; de = safe_readdir(d) ) { 
    146146 
    147147            if (de->d_name[0] == 0xE5 /* deleted entry */ ) 
     
    155155 
    156156                sprintf(buf, "%s/%s", curdir, de->d_name); 
    157                 if (stat(buf, &st)!=0)  
     157                if (safe_stat(buf, &st)!=0)  
    158158                                continue; 
    159159                         
     
    213213                } 
    214214 
    215                 closedir(d); 
     215                safe_closedir(d); 
    216216 
    217217                // Iteration#1 final: allocate menuitems 
    218218                if (iter==1) { 
    219219 
    220                         if ( count==0 ) { closedir(d); return 0;} 
     220                        if ( count==0 ) { safe_closedir(d); return 0;} 
    221221 
    222222                        len = sizeof(CMenu) + sizeof(CMenuItem)*(count+2); 
  • trunk/core/modules/simple_module.c

    r1467 r1505  
    1212  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
    1313 **************************************************************/ 
    14  
    15 int _chdk_required_ver = 1;             // minimal required chdk build. 0-no limitation 
    16 int _chdk_required_platfid = 0;         // platform-specific module. 0-no limitation 
    1714 
    1815void* MODULE_EXPORT_LIST[] = { 
  • trunk/core/raw.c

    r1497 r1505  
    66#include "dng.h" 
    77#ifdef OPT_CURVES 
    8     #include "curves.h" 
     8    #include "modules.h" 
    99#endif 
    1010#include "shot_histogram.h" 
     
    7575        } 
    7676#ifdef OPT_CURVES 
    77         if (conf.curve_enable) curve_apply(); 
     77        if (conf.curve_enable) { 
     78                        if (module_curves_load()) 
     79                                curve_apply(); 
     80                } 
    7881#endif 
    7982        finished(); 
     
    181184 
    182185#ifdef OPT_CURVES 
    183     if (conf.curve_enable) curve_apply(); 
     186    if (conf.curve_enable) { 
     187                if (module_curves_load()) 
     188                        curve_apply(); 
     189        } 
    184190#endif 
    185191    return ret; 
  • trunk/core/raw_merge.c

    r1211 r1505  
    88#include "lang.h" 
    99#include "conf.h" 
     10#include "module_exportlist.h" 
     11 
    1012#define TEMP_FILE_NAME   "A/raw16.tmp" 
    1113#define TEMP_FILE_NAME_1 "A/raw16_1.tmp" 
     
    3537 int result; 
    3638 if ((from==0) || (sub==0)) return 0; // bad pixel 
    37  result = from - sub + CAM_BLACK_LEVEL; 
    38  if (result<CAM_BLACK_LEVEL) result=CAM_BLACK_LEVEL; 
    39  if (result>CAM_WHITE_LEVEL) result=CAM_WHITE_LEVEL; 
     39 result = from - sub + CAM_CHDK_BLACK_LEVEL; 
     40 if (result<CAM_CHDK_BLACK_LEVEL) result=CAM_CHDK_BLACK_LEVEL; 
     41 if (result>CAM_CHDK_WHITE_LEVEL) result=CAM_CHDK_WHITE_LEVEL; 
    4042 return result; 
    4143 
     
    5456    static struct utimbuf t; 
    5557 
    56     struct stat st; 
    57  
    58     if (stat((char *)from,&st) != 0 || st.st_size!=hook_raw_size())  
     58    struct STD_stat st; 
     59 
     60    if (safe_stat((char *)from,&st) != 0 || st.st_size!=hook_raw_size())  
    5961        return 0; 
    6062 
    61     if (stat((char *)sub,&st) != 0 || st.st_size!=hook_raw_size())  
     63    if (safe_stat((char *)sub,&st) != 0 || st.st_size!=hook_raw_size())  
    6264        return 0; 
    6365 
    64      if( (baccum=malloc(RAW_ROWLEN)) && 
    65         (bsub=malloc(RAW_ROWLEN)) && 
     66     if( (baccum=malloc(RAW_CHDK_ROWLEN)) && 
     67        (bsub=malloc(RAW_CHDK_ROWLEN)) && 
    6668        (ffrom=fopen(from, "rb")) && 
    6769        (fsub=fopen(sub, "rb")) && 
     
    7072    { 
    7173        started(); 
    72         for (j = 0; j < CAM_RAW_ROWS; j++) { 
    73             fread(baccum,1, RAW_ROWLEN,ffrom); 
    74             fread(bsub,1, RAW_ROWLEN,fsub); 
    75  
    76 #if CAM_SENSOR_BITS_PER_PIXEL==10 
    77  
    78             for(i = 0;i<RAW_ROWLEN; i+=10) { 
     74        for (j = 0; j < CAM_CHDK_RAW_ROWS; j++) { 
     75            fread(baccum,1, RAW_CHDK_ROWLEN,ffrom); 
     76            fread(bsub,1, RAW_CHDK_ROWLEN,fsub); 
     77 
     78#if CAM_MODULE_SENSOR_BITS_PER_PIXEL==10 
     79 
     80            for(i = 0;i<RAW_CHDK_ROWLEN; i+=10) { 
    7981                s =((0x3fc&(((unsigned short)bsub[i+1])<<2)) | (bsub[i+0] >> 6)); 
    8082                d =((0x3fc&(((unsigned short)baccum[i+1])<<2)) | (baccum[i+0] >> 6)); 
     
    129131            } 
    130132 
    131 #elif CAM_SENSOR_BITS_PER_PIXEL==12 
    132  
    133             for(i = 0;i<RAW_ROWLEN; i+=6) { 
     133#elif CAM_MODULE_SENSOR_BITS_PER_PIXEL==12 
     134 
     135            for(i = 0;i<RAW_CHDK_ROWLEN; i+=6) { 
    134136 
    135137                s=((0xFF0&(((unsigned short)bsub[i+1])<<4))   | (bsub[i+0] >> 4)); 
     
    162164#endif 
    163165 
    164             fwrite(baccum,1,RAW_ROWLEN,fdest); 
     166            fwrite(baccum,1,RAW_CHDK_ROWLEN,fdest); 
    165167            if ( (j & 0x1F) == 0 ) { 
    166                 gui_browser_progress_show((char *)dest, j*100/CAM_RAW_ROWS); 
     168                gui_browser_progress_show((char *)dest, j*100/CAM_CHDK_RAW_ROWS); 
    167169            } 
    168170        } 
     
    187189int raw_merge_start(int action){ 
    188190  unsigned int req, avail; 
    189   req=((CAM_RAW_ROWPIX*CAM_RAW_ROWS)>>18)+1; 
     191  req=((CAM_CHDK_RAW_ROWPIX*CAM_CHDK_RAW_ROWS)>>18)+1; 
    190192  avail=GetFreeCardSpaceKb()>>10; 
    191193  if (avail<req) { 
     
    196198  raw_action=action; 
    197199  raw_count=0; 
    198   row=malloc(CAM_RAW_ROWPIX*sizeof(unsigned short)); 
     200  row=malloc(CAM_CHDK_RAW_ROWPIX*sizeof(unsigned short)); 
    199201  if (!row) 
    200202    return 0; 
    201   rawrow=malloc(RAW_ROWLEN); 
     203  rawrow=malloc(RAW_CHDK_ROWLEN); 
    202204  if (!rawrow) { 
    203205    free(row); 
     
    210212  int  t,src,i,j,nrow; 
    211213  FILE *fbrawin=NULL,*fbrawout,*fcraw; 
    212   struct stat st; 
     214  struct STD_stat st; 
    213215 
    214216  if (!filename) 
    215217    return; 
    216218 
    217   stat(filename,&st); 
     219  safe_stat(filename,&st); 
    218220  if (st.st_size!=hook_raw_size()) 
    219221    return; 
     
    228230      fbrawout=fopen(TEMP_FILE_NAME_1,"w+b"); 
    229231      if (fbrawout){ 
    230         fread(rawrow, 1, RAW_ROWLEN, fcraw); 
     232        fread(rawrow, 1, RAW_CHDK_ROWLEN, fcraw); 
    231233        if (raw_count)  
    232           fread(row, 1, CAM_RAW_ROWPIX*sizeof(unsigned short), fbrawin);  
     234          fread(row, 1, CAM_CHDK_RAW_ROWPIX*sizeof(unsigned short), fbrawin);  
    233235        else 
    234           for (i=0;i<CAM_RAW_ROWPIX;i++) 
     236          for (i=0;i<CAM_CHDK_RAW_ROWPIX;i++) 
    235237            row[i]=0; 
    236238 
    237         for (nrow=0,j=0;nrow<CAM_RAW_ROWS;nrow++,j++){ 
    238  
    239 #if CAM_SENSOR_BITS_PER_PIXEL==10 
    240  
    241           for (i=0,src=0; i<CAM_RAW_ROWPIX; i+=8, src+=10){ 
     239        for (nrow=0,j=0;nrow<CAM_CHDK_RAW_ROWS;nrow++,j++){ 
     240 
     241#if CAM_MODULE_SENSOR_BITS_PER_PIXEL==10 
     242 
     243          for (i=0,src=0; i<CAM_CHDK_RAW_ROWPIX; i+=8, src+=10){ 
    242244            row[i+0]+=((0x3fc&(((unsigned short)rawrow[src+1])<<2)) | (rawrow[src+0] >> 6)); 
    243245            row[i+1]+=((0x3f0&(((unsigned short)rawrow[src+0])<<4)) | (rawrow[src+3] >> 4)); 
     
    250252          } 
    251253 
    252 #elif CAM_SENSOR_BITS_PER_PIXEL==12 
    253  
    254           for (i=0,src=0; i<CAM_RAW_ROWPIX; i+=4, src+=6){ 
     254#elif CAM_MODULE_SENSOR_BITS_PER_PIXEL==12 
     255 
     256          for (i=0,src=0; i<CAM_CHDK_RAW_ROWPIX; i+=4, src+=6){ 
    255257            row[i+0]+=((0xFF0&(((unsigned short)rawrow[src+1])<<4)) | (rawrow[src+0] >> 4)); 
    256258            row[i+1]+=((0xF00&(((unsigned short)rawrow[src+0])<<8)) | (rawrow[src+3]     )); 
     
    263265#endif 
    264266 
    265           fwrite(row, 1, CAM_RAW_ROWPIX*sizeof(unsigned short), fbrawout); 
     267          fwrite(row, 1, CAM_CHDK_RAW_ROWPIX*sizeof(unsigned short), fbrawout); 
    266268          if (raw_count) 
    267             fread(row, 1, CAM_RAW_ROWPIX*sizeof(unsigned short), fbrawin); 
     269            fread(row, 1, CAM_CHDK_RAW_ROWPIX*sizeof(unsigned short), fbrawin); 
    268270          else 
    269             for (i=0;i<CAM_RAW_ROWPIX;i++) 
     271            for (i=0;i<CAM_CHDK_RAW_ROWPIX;i++) 
    270272              row[i]=0; 
    271           fread(rawrow, 1, RAW_ROWLEN, fcraw); 
    272           if (j>=CAM_RAW_ROWS/10) { 
    273             j-=CAM_RAW_ROWS/10; 
    274             gui_browser_progress_show(filename, nrow*100/CAM_RAW_ROWS); 
     273          fread(rawrow, 1, RAW_CHDK_ROWLEN, fcraw); 
     274          if (j>=CAM_CHDK_RAW_ROWS/10) { 
     275            j-=CAM_CHDK_RAW_ROWS/10; 
     276            gui_browser_progress_show(filename, nrow*100/CAM_CHDK_RAW_ROWS); 
    275277          } 
    276278        } 
     
    307309    fcraw=fopen(namebuf,"w+b"); 
    308310    if (fcraw) { 
    309       fread(row, 1, CAM_RAW_ROWPIX*sizeof(unsigned short), fbraw); 
    310       for (nrow=0,j=0;nrow<CAM_RAW_ROWS;nrow++,j++) { 
    311         for (i=0;i<CAM_RAW_ROWPIX;i++) { 
     311      fread(row, 1, CAM_CHDK_RAW_ROWPIX*sizeof(unsigned short), fbraw); 
     312      for (nrow=0,j=0;nrow<CAM_CHDK_RAW_ROWS;nrow++,j++) { 
     313        for (i=0;i<CAM_CHDK_RAW_ROWPIX;i++) { 
    312314          if (raw_action==RAW_OPERATION_AVERAGE) 
    313315            row[i]/=raw_count; 
    314316          else { 
    315             if (row[i]>CAM_BLACK_LEVEL*(raw_count-1)) 
    316               row[i]-=CAM_BLACK_LEVEL*(raw_count-1); 
     317            if (row[i]>CAM_CHDK_BLACK_LEVEL*(raw_count-1)) 
     318              row[i]-=CAM_CHDK_BLACK_LEVEL*(raw_count-1); 
    317319            else 
    318320              row[i]=0; 
    319             if (row[i]>CAM_WHITE_LEVEL) 
    320               row[i]=CAM_WHITE_LEVEL; 
     321            if (row[i]>CAM_CHDK_WHITE_LEVEL) 
     322              row[i]=CAM_CHDK_WHITE_LEVEL; 
    321323          } 
    322324        } 
    323 #if CAM_SENSOR_BITS_PER_PIXEL==10 
    324         for (i=0,src=0;i<CAM_RAW_ROWPIX;i+=8,src+=10) { 
     325#if CAM_MODULE_SENSOR_BITS_PER_PIXEL==10 
     326        for (i=0,src=0;i<CAM_CHDK_RAW_ROWPIX;i+=8,src+=10) { 
    325327          rawrow[src+0]=(row[i+0]<<6)|(row[i+1]>>4); 
    326328          rawrow[src+1]=(row[i+0]>>2); 
     
    334336          rawrow[src+9]=(row[i+6]<<2)|(row[i+7]>>8); 
    335337        } 
    336 #elif CAM_SENSOR_BITS_PER_PIXEL==12 
    337         for (i=0,src=0; i<CAM_RAW_ROWPIX; i+=4, src+=6){ 
     338#elif CAM_MODULE_SENSOR_BITS_PER_PIXEL==12 
     339        for (i=0,src=0; i<CAM_CHDK_RAW_ROWPIX; i+=4, src+=6){ 
    338340          rawrow[src+0]=(row[i+0]<<4)|(row[i+1]>>8); 
    339341          rawrow[src+1]=(row[i+0]>>4); 
     
    347349#endif 
    348350 
    349         fwrite(rawrow, 1, RAW_ROWLEN, fcraw); 
    350         fread(row, 1, CAM_RAW_ROWPIX*sizeof(unsigned short), fbraw); 
    351         if (j>=CAM_RAW_ROWS/5) { 
    352           j-=CAM_RAW_ROWS/5; 
    353           gui_browser_progress_show(namebuf, nrow*100/CAM_RAW_ROWS); 
     351        fwrite(rawrow, 1, RAW_CHDK_ROWLEN, fcraw); 
     352        fread(row, 1, CAM_CHDK_RAW_ROWPIX*sizeof(unsigned short), fbraw); 
     353        if (j>=CAM_CHDK_RAW_ROWS/5) { 
     354          j-=CAM_CHDK_RAW_ROWS/5; 
     355          gui_browser_progress_show(namebuf, nrow*100/CAM_CHDK_RAW_ROWS); 
    354356        } 
    355357      } 
     
    368370} 
    369371 
     372 
     373// =========  MODULE INIT ================= 
     374#include "module_load.h" 
     375int module_idx=-1; 
     376 
     377/***************** BEGIN OF AUXILARY PART ********************* 
     378  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     379 **************************************************************/ 
     380 
     381void* MODULE_EXPORT_LIST[] = { 
     382        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     383        /* 1 */ (void*)6, 
     384 
     385                        raw_merge_start, 
     386                        raw_merge_add_file, 
     387                        raw_merge_end, 
     388                        raw_subtract 
     389                }; 
     390 
     391 
     392//--------------------------------------------------------- 
     393// PURPOSE:   Bind module symbols with chdk.  
     394//              Required function 
     395// PARAMETERS: pointer to chdk list of export 
     396// RETURN VALUE: 1 error, 0 ok 
     397//--------------------------------------------------------- 
     398int _module_loader( void** chdk_export_list ) 
     399{ 
     400  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     401     return 1; 
     402 
     403  return 0; 
     404} 
     405 
     406 
     407 
     408//--------------------------------------------------------- 
     409// PURPOSE: Finalize module operations (close allocs, etc) 
     410// RETURN VALUE: 0-ok, 1-fail 
     411//--------------------------------------------------------- 
     412int _module_unloader() 
     413{ 
     414  return 0; 
     415} 
     416 
     417 
     418/******************** Module Information structure ******************/ 
     419 
     420struct ModuleInfo _module_info = {      MODULEINFO_V1_MAGICNUM, 
     421                                                                        sizeof(struct ModuleInfo), 
     422 
     423                                                                        ANY_CHDK_BRANCH, 0,                     // Requirements of CHDK version 
     424                                                                        ANY_PLATFORM_ALLOWED,           // Specify platform dependency 
     425                                                                        MODULEINFO_FLAG_SYSTEM,         // flag 
     426#if CAM_MODULE_SENSOR_BITS_PER_PIXEL==10 
     427                                                                        (int32_t)"RAW operations-10bpp(dll)",// Module name 
     428#else 
     429                                                                        (int32_t)"RAW operations-12bpp(dll)",// Module name 
     430#endif 
     431                                                                        1, 0,                                           // Module version 
     432#if CAM_MODULE_SENSOR_BITS_PER_PIXEL==10 
     433                                                                        (int32_t)"Implementation of RAW operations\n(Avg, Sum, Sub) for 10bit sensor" 
     434#else 
     435                                                                        (int32_t)"Implementation of RAW operations\n(Avg, Sum, Sub) for 12bit sensor" 
     436#endif 
     437                                                                 }; 
     438 
     439 
     440/*************** END OF AUXILARY PART *******************/ 
  • trunk/core/raw_merge.h

    r594 r1505  
    55#define RAW_OPERATION_AVERAGE 1 
    66 
     7 
     8struct librawop_sym{ 
     9        int (*raw_merge_start)(int action); 
     10        void (*raw_merge_add_file)(const char * filename); 
     11        void (*raw_merge_end)(void); 
     12        int (*raw_subtract)(const char *from, const char *sub, const char *dest);  
     13}; 
     14 
     15// Defines of exported to chdk symbols 
     16#ifdef THIS_IS_CHDK_CORE 
     17        // This section is for CHDK core 
     18 
     19        extern struct librawop_sym librawop; 
     20 
     21#else 
     22        // This section is for module 
     23 
    724int raw_merge_start(int action); 
    825void raw_merge_add_file(const char * filename); 
     
    1027int raw_subtract(const char *from, const char *sub, const char *dest);  
    1128#endif 
     29 
     30#endif 
  • trunk/core/script.c

    r1437 r1505  
    593593                    extern char* gui_fselect_result(); 
    594594                    // Send file name back to script caller 
    595                     lua_pushstring( Lt, gui_fselect_result() ); 
     595                  ////  lua_pushstring( Lt, gui_fselect_result() ); 
    596596                } 
    597597#endif 
  • trunk/include/gui.h

    r1338 r1505  
    88 
    99// Don't delete or re-order entries unless guiHandlers (gui.c) table is updated to match  
    10 enum Gui_Mode { 
     10enum Gui_Mode_ { 
    1111    GUI_MODE_NONE = 0, 
    1212    GUI_MODE_ALT, 
     
    1414    GUI_MODE_PALETTE, 
    1515    GUI_MODE_MBOX, 
    16     GUI_MODE_REVERSI, 
    17     GUI_MODE_SOKOBAN, 
    18     GUI_MODE_DEBUG, 
    1916    GUI_MODE_FSELECT, 
    20     GUI_MODE_READ, 
    2117    GUI_MODE_OSD, 
    22     GUI_MODE_CALENDAR, 
    23     GUI_MODE_BENCH, 
    2418    GUI_MODE_MPOPUP, 
    25     GUI_MODE_4WINS, 
    26     GUI_MODE_MASTERMIND 
     19        GUI_MODE_COUNT 
    2720}; 
     21 
     22 
     23typedef unsigned int gui_mode_t; 
     24 
     25#define GUI_MODE_MAGICNUM       0xd36c1559 
     26 
     27// Specific behaviour of gui mode 
     28#define GUI_MODE_FLAG_NODRAWRESTORE       1 
     29#define GUI_MODE_FLAG_NORESTORE_ON_SWITCH 2 
     30// Binded to module gui mode 
     31#define GUI_MODE_FLAG_ALIAS                               4 
     32 
     33 
     34// Values (bit-flag) for gui_draw argument 
     35#define GUI_REDRAWFLAG_ERASEGUARD       1 
     36#define GUI_REDRAWFLAG_MODE_WAS_CHANGED 2 
     37#define GUI_REDRAWFLAG_DRAW_RESTORED    4 
     38 
     39// Structure to store gui redraw and kbd process handlers for each mode 
     40typedef struct 
     41{ 
     42        // Called to redraw screen. Argument is GUI_REDRAWFLAG_* set 
     43    void (*redraw)(int); 
     44 
     45        // Main button handler for mode 
     46        // Note: this pointer reused as gui_handler* for  
     47        //    GUI_MODE_FLAG_ALIAS entries 
     48        // Do not use union because warning on initializer 
     49    void (*kbd_process)(void); 
     50 
     51        // Menu button handler for mode 
     52    void (*kbd_process_menu_btn)(void); 
     53 
     54        int flags; 
     55 
     56        // Safety check for modules 
     57        unsigned int magicnum; 
     58} gui_handler; 
     59 
     60 
     61 
     62void gui_default_kbd_process_menu_btn(); 
    2863 
    2964extern void gui_redraw(); 
     
    3267extern void draw_pixel(coord x, coord y, color cl); 
    3368 
    34 extern enum Gui_Mode gui_get_mode(); 
    35 extern void gui_set_mode(enum Gui_Mode mode); 
     69extern gui_mode_t gui_get_mode(); 
     70extern void gui_set_mode(gui_mode_t mode); 
     71 
     72extern int gui_bind_mode(int core_mode, gui_handler* handler); 
     73 
     74 
    3675 
    3776#ifdef OPT_SCRIPTING 
     
    3978#endif 
    4079 
     80extern void gui_menu_run_fltmodule(int arg); 
     81 
    4182#endif 
  • trunk/include/lang.h

    <
    r1393 r1505  
    55extern void lang_init(int num); 
    66 
    7 extern void lang_parse_from_mem(char *buf); 
    87extern void lang_load_from_file(const char *filename); 
    98extern void lang_map_preparsed_from_mem( char* gui_lang_default, int num );