Changeset 1467


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

apply 1459_elf3.patch from tsvstar in http://chdk.setepontos.com/index.php?topic=847.msg77723#msg77723
workaround in kbd.c for trunk changesets 1461 and 1464
set eol-style props

Location:
branches/reyalp-flt
Files:
26 added
49 edited

Legend:

Unmodified
Added
Removed
  • branches/reyalp-flt/Makefile

    r1371 r1467  
    8181      endif 
    8282    endif 
     83        rm -f $(topdir)CHDK/MODULES/* 
     84        cp $(topdir)core/modules/*.flt $(topdir)CHDK/MODULES 
     85        zip -9 $(topdir)bin/$(VER)-$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)CHDK/MODULES/* 
    8386        # if COPY_TO is defined then copy this camera/firmware version to the copied firmware version 
    8487        # Define COPY_TO in $(topdir)/platform/$(PLATFORM)/sub/$(PLATFORMSUB)/makefile.inc of the source 
     
    9396    endif 
    9497        rm -f $(topdir)bin/DISKBOOT.BIN 
     98        rm -f $(topdir)CHDK/MODULES/* 
     99        rm -f $(topdir)core/modules/*.flt 
    95100 
    96101 
     
    128133        zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)doc/readme.txt  > $(DEVNULL) 
    129134        zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)doc/readme.txt  > $(DEVNULL) 
     135        rm -f $(topdir)CHDK/MODULES/* 
     136        cp $(topdir)core/modules/*.flt $(topdir)CHDK/MODULES 
     137        zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)CHDK/MODULES/*  > $(DEVNULL) 
     138        zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)CHDK/MODULES/*  > $(DEVNULL) 
     139        rm -f $(topdir)CHDK/MODULES/* 
     140        rm -f $(topdir)core/modules/*.flt 
    130141 
    131142    ifdef PLATFORMOS 
  • branches/reyalp-flt/core/Makefile

    r1465 r1467  
    1010LDOPTS+=-Wl,-N,-Ttext,$(MEMISOSTART) 
    1111 
     12SUBDIRS=modules 
     13 
    1214all: main.bin 
     15 
     16# Core CHDK flag 
     17CFLAGS+=-DTHIS_IS_CHDK_CORE 
    1318 
    1419OPT_OBJS= 
    1520ifdef OPT_GAME_REVERSI 
    1621CFLAGS+=-DOPT_GAME_REVERSI 
    17 OPT_OBJS+=gui_reversi.o 
     22#OPT_OBJS+=gui_reversi.o 
    1823endif 
    1924ifdef OPT_GAME_SOKOBAN 
    2025CFLAGS+=-DOPT_GAME_SOKOBAN 
    21 OPT_OBJS+=gui_sokoban.o 
     26#OPT_OBJS+=gui_sokoban.o 
    2227endif 
    2328ifdef OPT_GAME_CONNECT4 
    2429CFLAGS+=-DOPT_GAME_CONNECT4 
    25 OPT_OBJS+=gui_4wins.o 
     30#OPT_OBJS+=gui_4wins.o 
    2631endif 
    2732ifdef OPT_GAME_MASTERMIND 
    2833CFLAGS+=-DOPT_GAME_MASTERMIND 
    29 OPT_OBJS+=gui_mastermind.o 
     34#OPT_OBJS+=gui_mastermind.o 
    3035endif 
    3136ifdef OPT_CURVES 
    3237CFLAGS+=-DOPT_CURVES 
    33 OPT_OBJS+=curves.o 
     38#OPT_OBJS+=curves.o 
    3439endif 
    3540ifdef OPT_TEXTREADER 
    3641CFLAGS+=-DOPT_TEXTREADER 
    37 OPT_OBJS+=gui_read.o  
     42#OPT_OBJS+=gui_read.o  
    3843endif 
    3944ifdef OPT_CALENDAR 
    4045CFLAGS+=-DOPT_CALENDAR 
    41 OPT_OBJS+=gui_calendar.o  
     46#OPT_OBJS+=gui_calendar.o  
    4247endif 
    4348ifdef OPT_DEBUGGING 
    4449# global in root makefile.inc 
    4550#CFLAGS+=-DOPT_DEBUGGING 
    46 OPT_OBJS+=gui_debug.o gui_bench.o  
     51#OPT_OBJS+=gui_debug.o gui_bench.o  
    4752endif 
    4853ifdef OPT_EDGEOVERLAY 
    4954CFLAGS+=-DOPT_EDGEOVERLAY 
    50 OPT_OBJS+=edgeoverlay.o  
     55#OPT_OBJS+=edgeoverlay.o  
    5156endif 
    5257ifdef OPT_MD_DEBUG 
     
    7277endif 
    7378 
    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 \ 
     79OBJS=entry.o main.o gui_draw.o gui_menu.o gui_mbox.o \ 
     80     gui.o kbd.o action_stack.o conf.o\ 
    7681     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 \ 
     82     gui_usb.o gui_lang.o gui_grid.o modules.o module_load.o\ 
    7883     levent.o shot_histogram.o dng.o bitvector.o console.o $(OPT_OBJS) 
    7984 
     
    113118        rm -f $(OBJS:.o=.d) 
    114119 
     120module_load.o: module_load.c module_load.h module_exportlist.c module_exportlist.h flt.h 
     121 
     122module_exportlist.h: $(topdir)tools/makeexport$(EXE) module_exportlist.c 
     123        @echo $< \-\> $@ 
     124        $(topdir)tools/makeexport$(EXE) module_exportlist.c module_exportlist.h modules/exportlist.txt 
     125 
     126flt.h: $(topdir)tools/elf2flt/flt.h 
     127        @echo $< \-\> $@ 
     128        @echo "//DO NOT EDIT THIS FILE. This is automatic copy of tools/elf2flt/flt.h" > flt.h 
     129        cat $(topdir)tools/elf2flt/flt.h >>flt.h 
     130 
    115131gui_lang.o: gui_lang.c gui_lang.h gui_lang_str.h 
    116132 
  • branches/reyalp-flt/core/curves.c

    r727 r1467  
    44#include "raw.h" 
    55 
    6 #ifdef OPT_CURVES 
     6//#ifdef OPT_CURVES 
     7#if 1 
    78 
    89#include "curves.h" 
     10 
     11char *conf_curve_file; 
     12int *conf_curve_enable; 
    913 
    1014/* 
     
    101105 
    102106void curve_set_mode(int value) { 
    103         if((value>=0) && (value<=4)) conf.curve_enable=value; 
     107        if((value>=0) && (value<=4)) *conf_curve_enable=value; 
    104108        curve_init_mode(); 
    105109} 
    106110 
    107111void curve_init_mode() { 
    108         switch(conf.curve_enable) { 
     112        switch(*conf_curve_enable) { 
    109113                case 1: // custom - ensure alloc and load conf.curve_file 
    110                         curve_load_data(conf.curve_file,CURVE_CUSTOM); 
     114                        curve_load_data(conf_curve_file,CURVE_CUSTOM); 
    111115                break; 
    112116                case 2: // system - ensure alloc and load syscurve 
     
    116120                break; 
    117121                default: 
    118                         conf.curve_enable = 0; 
     122                        *conf_curve_enable = 0; 
    119123                case 0: // disabled - free 
    120124                        curve_free_data(); 
     
    371375        short EVbias = shooting_get_ev_correction1(); 
    372376 
    373         switch(conf.curve_enable) { 
     377        switch(*conf_curve_enable) { 
    374378                case 0: 
    375379                        break; 
     
    385389                case 2: 
    386390                case 3: // +1EV,  +2EV 
    387                         if (current_curve_type == CURVE_SYSTEM) curveL_apply( conf.curve_enable & 1 ); 
     391                        if (current_curve_type == CURVE_SYSTEM) curveL_apply( *conf_curve_enable & 1 ); 
    388392                        break; 
    389393                case 4:         // Auto DR 
     
    401405} 
    402406 
     407// =========  MODULE INIT ================= 
     408 
     409#include "module_load.h" 
     410 
     411 
     412int module_idx=-1; 
     413 
     414/***************** BEGIN OF AUXILARY PART ********************* 
     415  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     416 **************************************************************/ 
     417 
     418int _chdk_required_ver = 1;             // minimal required chdk build. 0-no limitation 
     419int _chdk_required_platfid = 0;         // platform-specific module. 0-no limitation 
     420 
     421void* MODULE_EXPORT_LIST[] = { 
     422        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     423        /* 1 */ (void*)5, 
     424 
     425                        curve_set_mode, 
     426                        curve_init_mode, 
     427                        curve_apply, 
     428                }; 
     429 
     430 
     431//--------------------------------------------------------- 
     432// PURPOSE:   Bind module symbols with chdk.  
     433//              Required function 
     434// PARAMETERS: pointer to chdk list of export 
     435// RETURN VALUE: 1 error, 0 ok 
     436//--------------------------------------------------------- 
     437int _module_loader( void** chdk_export_list ) 
     438{ 
     439  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     440     return 1; 
     441 
     442  // Safe bind of conf. 
     443  tConfigVal configVal; 
     444  CONF_BIND_STR(185, conf_curve_file); 
     445  CONF_BIND_INT(186, conf_curve_enable ); 
     446 
     447  // Startup initialize 
     448  curve_init_mode(); 
     449 
     450  return 0; 
     451} 
     452 
     453 
     454 
     455//--------------------------------------------------------- 
     456// PURPOSE: Finalize module operations (close allocs, etc) 
     457// RETURN VALUE: 0-ok, 1-fail 
     458//--------------------------------------------------------- 
     459int _module_unloader() 
     460{ 
     461        // This could be happens only if on-load mistake 
     462        // CHDK never unload this library (but load only if needed) 
     463        // Reason: a) curve_set_mode by LUA is not stored anywhere 
     464        //                 b) perfomance reason - to avoid load on each raw_processing 
     465  return 0; 
     466} 
     467 
     468 
     469 
     470/*************** END OF AUXILARY PART *******************/ 
     471 
     472 
    403473#endif 
  • branches/reyalp-flt/core/curves.h

    r709 r1467  
    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 
  • branches/reyalp-flt/core/edgeoverlay.c

    r1365 r1467  
    11#include "platform.h" 
    22 
    3 #ifdef OPT_EDGEOVERLAY 
    43#include "edgeoverlay.h" 
    54#include "conf.h" 
     
    1413#define EDGE_SLICES     2 
    1514 
     15int* conf_edge_overlay_filter; 
     16color* conf_osd_color; 
     17int* conf_edge_overlay_zoom; 
     18int* conf_edge_overlay_thresh; 
     19color* conf_edge_overlay_color; 
     20int* conf_edge_overlay_pano; 
     21int* conf_edge_overlay_pano_overlap; 
     22int* conf_edge_overlay_show; 
     23int* conf_edge_overlay_play; 
     24 
    1625typedef enum _edge_fsm_state 
    1726{ 
     
    5463            memset(edgebuf->ptr, 0, edgebuf->ptrLen); 
    5564    } 
    56     if (conf.edge_overlay_filter && (smbuf == NULL)) 
     65    if (*conf_edge_overlay_filter && (smbuf == NULL)) 
    5766    { 
    5867        smbuf = (unsigned char*)malloc(viewport_byte_width*3); 
     
    6271        { 
    6372            // Disable filtering if we do not have enough memory for it 
    64             conf.edge_overlay_filter = 0; 
     73            *conf_edge_overlay_filter = 0; 
    6574        } 
    6675    } 
     
    133142    if( !is_buffer_ready() ) 
    134143    { 
    135         draw_string(0, 0, "No overlay to save.", conf.osd_color); 
     144        draw_string(0, 0, "No overlay to save.", *conf_osd_color); 
    136145        return; 
    137146    } 
     
    168177        utime(fn, &t); 
    169178        sprintf(msg, "Saved as %s",fn); 
    170         draw_string(0, 0, msg, conf.osd_color); 
     179        draw_string(0, 0, msg, *conf_osd_color); 
    171180    } 
    172181    closedir(d); 
     
    190199        { 
    191200            fsm_state = EDGE_FROZEN;    // switch to "edge overlay frozen"-mode 
    192             if (conf.edge_overlay_zoom) 
     201            if (*conf_edge_overlay_zoom) 
    193202            { 
    194203                shooting_set_zoom(zoom); 
     
    298307    memset(edgebuf->ptr + slice*compressed_slice, 0, compressed_slice); 
    299308 
    300     if (conf.edge_overlay_filter) 
     309    if (*conf_edge_overlay_filter) 
    301310    { 
    302311        // Prefill smbuf with three lines of avergae-filtered data. 
     
    320329        shutter_fullpress |= kbd_is_key_pressed(KEY_SHOOT_FULL); 
    321330 
    322         if (conf.edge_overlay_filter) 
     331        if (*conf_edge_overlay_filter) 
    323332        { 
    324333            // We need to shift up our smbuf one line, 
     
    372381                conv2 = -conv2; 
    373382 
    374             if (conv1 + conv2 > conf.edge_overlay_thresh) 
     383            if (conv1 + conv2 > *conf_edge_overlay_thresh) 
    375384            { 
    376385                bv_set(edgebuf, (y-viewport_yoffset-EDGE_HMARGIN)*viewport_width + xdiv3, 1); 
     
    402411                conv2 = -conv2; 
    403412 
    404             if (conv1 + conv2 > conf.edge_overlay_thresh) 
     413            if (conv1 + conv2 > *conf_edge_overlay_thresh) 
    405414            { 
    406415                bv_set(edgebuf, (y-viewport_yoffset-EDGE_HMARGIN)*viewport_width + xdiv3+1, 1); 
     
    416425//  care so much about performance, you can enable it. 
    417426// 
    418 //    if (conf.edge_overlay_filter) 
     427//    if (*conf_edge_overlay_filter) 
    419428//    { 
    420429//        // Here we do basic filtering on the detected edges. 
     
    451460//                            bv_get(edgebuf, (y+1)*viewport_width + (x+1)); 
    452461// 
    453 //                        if (!conf.edge_overlay_show) 
     462//                        if (!*conf_edge_overlay_show) 
    454463//                        { 
    455464//                            if (sum >= 5)    // if we have at least 5 neighboring edges 
     
    479488    int x_off, y_off; 
    480489 
    481     const color cl = conf.edge_overlay_color; 
     490    const color cl = *conf_edge_overlay_color; 
    482491    const int y_slice_min = viewport_yoffset+EDGE_HMARGIN+ slice   *slice_height; 
    483492    const int y_slice_max = viewport_yoffset+EDGE_HMARGIN+(slice+1)*slice_height; 
     
    510519                    const int aspect_correct_x_off = x_off; 
    511520                    const int bEdge = bv_get(edgebuf, y_edgebuf + x); 
    512                     const int bDraw = bEdge || (draw_get_pixel(aspect_correct_x_off, y_off) == conf.edge_overlay_color); 
    513                     const color cl = bEdge ? conf.edge_overlay_color : 0; 
     521                    const int bDraw = bEdge || (draw_get_pixel(aspect_correct_x_off, y_off) == *conf_edge_overlay_color); 
     522                    const color cl = bEdge ? *conf_edge_overlay_color : 0; 
    514523                    if (bEdge || bDraw) 
    515524                        draw_pixel(aspect_correct_x_off, y_off, cl); 
     
    569578    const int x_max = (viewport_width - 2); 
    570579 
    571     switch(conf.edge_overlay_pano) 
     580    switch(*conf_edge_overlay_pano) 
    572581    { 
    573582    case 0:     // pano off 
     
    576585        break; 
    577586    case 1:     // pano from left to right 
    578         xoffset = -x_max*(100-conf.edge_overlay_pano_overlap)/100; 
     587        xoffset = -x_max*(100-*conf_edge_overlay_pano_overlap)/100; 
    579588        break; 
    580589    case 2:     // pano from top to bottom 
    581         yoffset = -y_max*(100-conf.edge_overlay_pano_overlap)/100; 
     590        yoffset = -y_max*(100-*conf_edge_overlay_pano_overlap)/100; 
    582591        break; 
    583592    case 3:     // pano from right to left 
    584         xoffset = x_max*(100-conf.edge_overlay_pano_overlap)/100; 
     593        xoffset = x_max*(100-*conf_edge_overlay_pano_overlap)/100; 
    585594        break; 
    586595    case 4:     // pano from bottom to top 
    587         yoffset = y_max*(100-conf.edge_overlay_pano_overlap)/100; 
     596        yoffset = y_max*(100-*conf_edge_overlay_pano_overlap)/100; 
    588597        break; 
    589598    case 5:     // free mode 
     
    594603    } 
    595604} 
     605 
    596606 
    597607 
     
    605615void edge_overlay() 
    606616{ 
    607  
    608617    // Was the shutter fully pressed the last time we ran? 
    609618    // We use this to make sure that the user has released 
     
    623632    const int bHalfPress = kbd_is_key_pressed(KEY_SHOOT_HALF); 
    624633    const int bPlayMode = (mode_get() & MODE_MASK) == MODE_PLAY; 
    625     const int bPanoramaMode = (conf.edge_overlay_pano != 0); 
    626     const int bNeedHalfPress = (conf.edge_overlay_show != 1); 
    627     const int bDisplayInPlay = (conf.edge_overlay_play == 1); 
     634    const int bPanoramaMode = (*conf_edge_overlay_pano != 0); 
     635    const int bNeedHalfPress = (*conf_edge_overlay_show != 1); 
     636    const int bDisplayInPlay = (*conf_edge_overlay_play == 1); 
    628637    const int bGuiModeNone = (gui_get_mode() == GUI_MODE_NONE); 
    629638    const int bGuiModeAlt = (gui_get_mode() == GUI_MODE_ALT); 
     
    708717            // calculations. 
    709718            bFullPress |= draw_edge_overlay(); 
    710             draw_string(0, 0, "Frozen", conf.osd_color); 
     719            draw_string(0, 0, "Frozen", *conf_osd_color); 
    711720        } 
    712721 
     
    741750}   // function 
    742751 
    743 #endif 
    744  
     752 
     753 
     754 
     755 
     756// =========  MODULE INIT ================= 
     757 
     758#include "module_load.h" 
     759int module_idx=-1; 
     760 
     761/***************** BEGIN OF AUXILARY PART ********************* 
     762  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     763 **************************************************************/ 
     764 
     765int _chdk_required_ver = 1;             // minimal required chdk build. 0-no limitation 
     766int _chdk_required_platfid = 0;         // platform-specific module. 0-no limitation 
     767 
     768void* MODULE_EXPORT_LIST[] = { 
     769        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     770        /* 1 */ (void*)5, 
     771 
     772                        edge_overlay, 
     773                        save_edge_overlay, 
     774                        load_edge_overlay 
     775                }; 
     776 
     777 
     778//--------------------------------------------------------- 
     779// PURPOSE:   Bind module symbols with chdk.  
     780//              Required function 
     781// PARAMETERS: pointer to chdk list of export 
     782// RETURN VALUE: 1 error, 0 ok 
     783//--------------------------------------------------------- 
     784int _module_loader( void** chdk_export_list ) 
     785{ 
     786  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     787     return 1; 
     788 
     789  tConfigVal configVal; 
     790  CONF_BIND_INT(188, conf_edge_overlay_thresh); 
     791  CONF_BIND_COLOR(189, conf_edge_overlay_color); 
     792  CONF_BIND_INT(222, conf_edge_overlay_play); 
     793  CONF_BIND_INT(223, conf_edge_overlay_pano); 
     794  CONF_BIND_INT(224, conf_edge_overlay_zoom); 
     795  CONF_BIND_INT(241, conf_edge_overlay_filter); 
     796  CONF_BIND_INT(242, conf_edge_overlay_show); 
     797  CONF_BIND_INT(243, conf_edge_overlay_pano_overlap); 
     798  CONF_BIND_COLOR( 28, conf_osd_color); 
     799 
     800  return 0; 
     801} 
     802 
     803 
     804 
     805//--------------------------------------------------------- 
     806// PURPOSE: Finalize module operations (close allocs, etc) 
     807// RETURN VALUE: 0-ok, 1-fail 
     808//--------------------------------------------------------- 
     809int _module_unloader() 
     810{ 
     811        // This could be happens only if on-load mistake 
     812        // CHDK never unload this library (but load only if needed) 
     813        // Reason: edve_overlay allocate different bufs which should be kept 
     814        //              because even if we turn off edgeovr we could turn on back and 
     815        //              should get same content. 
     816  return 0; 
     817} 
     818 
     819 
     820 
     821/*************** END OF AUXILARY PART *******************/ 
     822 
  • branches/reyalp-flt/core/edgeoverlay.h

    r928 r1467  
    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 
  • branches/reyalp-flt/core/gui.c

    r1459 r1467  
    5050#endif 
    5151#ifdef OPT_EDGEOVERLAY 
    52         #include "edgeoverlay.h" 
     52        #include "modules.h" 
    5353#endif 
    5454#ifdef OPT_SCRIPTING 
     
    5656    int script_params_has_changed=0; 
    5757#endif 
     58#include "module_load.h" 
     59 
    5860//------------------------------------------------------------------- 
    5961 
     
    171173        static void gui_debug_shortcut(void); 
    172174        static void save_romlog(int arg); 
     175        static void gui_draw_modinspector(int arg); 
    173176#endif 
    174177static void gui_draw_fselect(int arg); 
     
    377380    MENU_ITEM(0x5c,LANG_MENU_DEBUG_SHOW_MISC_VALS,    MENUITEM_BOOL,          &conf.debug_misc_vals_show, 0 ), 
    378381    MENU_ITEM(0x2a,LANG_MENU_DEBUG_MEMORY_BROWSER,    MENUITEM_PROC,          gui_draw_debug, 0 ), 
     382    MENU_ITEM(0x2a,(int)"Module Inspector",                       MENUITEM_PROC,          gui_draw_modinspector, 0 ), 
    379383    MENU_ITEM(0x2a,LANG_MENU_DEBUG_BENCHMARK,         MENUITEM_PROC,          gui_draw_bench, 0 ), 
    380384    MENU_ENUM2(0x5c,LANG_MENU_DEBUG_SHORTCUT_ACTION,  &conf.debug_shortcut_action, gui_debug_shortcut_modes ), 
     
    10841088    gui_enum_value_change(&conf.curve_enable,change,sizeof(modes)/sizeof(modes[0])); 
    10851089 
    1086         if(change) 
     1090        if(change && curve_init_mode) 
    10871091                curve_init_mode(); 
    10881092    return modes[conf.curve_enable]; 
     
    11371141 
    11381142void gui_load_script(int arg) { 
    1139     gui_fselect_init(LANG_STR_SELECT_SCRIPT_FILE, conf.script_file, "A/CHDK/SCRIPTS", gui_load_script_selected); 
     1143    module_fselect_init(LANG_STR_SELECT_SCRIPT_FILE, conf.script_file, "A/CHDK/SCRIPTS", gui_load_script_selected); 
    11401144} 
    11411145 
     
    15161520void gui_raw_develop(int arg){ 
    15171521 int m=mode_get(); 
    1518  gui_fselect_init(LANG_RAW_DEVELOP_SELECT_FILE, "A/DCIM", "A", raw_fselect_cb); 
     1522 module_fselect_init(LANG_RAW_DEVELOP_SELECT_FILE, "A/DCIM", "A", raw_fselect_cb); 
    15191523} 
    15201524 
     
    16291633 
    16301634//------------------------------------------------------------------- 
    1631 static volatile enum Gui_Mode gui_mode; 
     1635static 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) 
     1636 
    16321637static volatile int gui_restore; 
    16331638static volatile int gui_in_redraw; 
     
    16371642static Conf old_conf; 
    16381643#endif 
     1644 
     1645extern gui_handler guiHandlers[]; 
    16391646 
    16401647//------------------------------------------------------------------- 
     
    16591666#ifdef OPT_CURVES 
    16601667        // initialize curves, loading files if required by current mode 
    1661         curve_init_mode(); 
     1668        //curve_init_mode();    // @tsv it will be initialize on first load 
    16621669#endif 
    16631670#if ZOOM_OVERRIDE 
     
    16731680                // TODO we could sanity check here, but curve_set_type should fail gracefullish 
    16741681                strcpy(conf.curve_file,fn); 
    1675                 if(conf.curve_enable == 1) 
     1682                if(conf.curve_enable == 1 && curve_init_mode) 
    16761683                        curve_init_mode(); 
    16771684        } 
     
    16801687//------------------------------------------------------------------- 
    16811688void gui_load_curve(int arg) { 
    1682     gui_fselect_init(LANG_STR_SELECT_CURVE_FILE, conf.curve_file, CURVE_DIR, gui_load_curve_selected); 
    1683 } 
    1684  
    1685 #endif 
    1686 //------------------------------------------------------------------- 
    1687 enum Gui_Mode gui_get_mode() { 
     1689    module_fselect_init(LANG_STR_SELECT_CURVE_FILE, conf.curve_file, CURVE_DIR, gui_load_curve_selected); 
     1690} 
     1691 
     1692#endif 
     1693//------------------------------------------------------------------- 
     1694gui_mode_t gui_get_mode() { 
    16881695    return gui_mode; 
    16891696} 
    16901697 
    16911698//------------------------------------------------------------------- 
    1692 void gui_set_mode(enum Gui_Mode mode) { 
     1699void gui_set_mode(gui_mode_t mode)  
     1700{ 
     1701        // Sanity check for case module pointer - is this really gui_handler 
     1702    if ( mode >= GUI_MODE_COUNT && ((gui_handler*)mode)->magicnum != GUI_MODE_MAGICNUM ) { 
     1703                // If sanity failed (module is unload) - set to default mode 
     1704        gui_mode = GUI_MODE_NONE; 
     1705                draw_restore(); 
     1706                return; 
     1707        } 
     1708         
    16931709#ifdef CAM_TOUCHSCREEN_UI 
    16941710    if (((gui_mode == 0) != (mode == 0)) ||                         // Change from GUI_MODE_NONE to any other or vice-versa 
     
    19601976} 
    19611977 
    1962 // Menu button handled for text reader 
    1963 #ifdef OPT_TEXTREADER 
    1964 void gui_read_kbd_process_menu_btn() 
    1965 { 
    1966     gui_read_kbd_process(); 
    1967     gui_default_kbd_process_menu_btn(); 
    1968 } 
    1969 #endif 
    1970  
    19711978// Menu button handled for Menu mode 
    19721979void gui_menu_kbd_process_menu_btn() 
     
    19871994 
    19881995//------------------------------------------------------------------- 
    1989 // Structure to store gui redraw and kbd process handlers for each mode 
    1990 typedef struct 
    1991 { 
    1992     void (*redraw)(void);                   // Called to redraw screen 
    1993     void (*kbd_process)(void);              // Main button handler for mode 
    1994     void (*kbd_process_menu_btn)(void);     // Menu button handler for mode 
    1995 } gui_handler; 
    1996  
    19971996// GUI handler table (entries must be in the same order and have the same number of entries as Gui_Mode enum) 
    19981997gui_handler guiHandlers[] = 
    19991998{ 
    2000     /*GUI_MODE_NONE*/           { gui_draw_osd,         0,                          0 }, 
    2001     /*GUI_MODE_ALT*/            { gui_chdk_draw,        gui_chdk_kbd_process,       gui_chdk_kbd_process_menu_btn }, 
    2002     /*GUI_MODE_MENU*/           { gui_menu_draw,        gui_menu_kbd_process,       gui_menu_kbd_process_menu_btn }, 
    2003     /*GUI_MODE_PALETTE*/        { gui_palette_draw,     gui_palette_kbd_process,    gui_default_kbd_process_menu_btn }, 
    2004     /*GUI_MODE_MBOX*/           { gui_mbox_draw,        gui_mbox_kbd_process,       0 }, 
    2005 #ifdef OPT_GAME_REVERSI 
    2006     /*GUI_MODE_REVERSI*/        { gui_reversi_draw,     gui_reversi_kbd_process,    gui_default_kbd_process_menu_btn }, 
    2007 #else 
    2008                                 { 0, 0, 0 }, 
    2009 #endif 
    2010 #ifdef OPT_GAME_SOKOBAN 
    2011     /*GUI_MODE_SOKOBAN*/        { gui_sokoban_draw,     gui_sokoban_kbd_process,    gui_default_kbd_process_menu_btn }, 
    2012 #else 
    2013                                 { 0, 0, 0 }, 
    2014 #endif 
    2015 #ifdef OPT_DEBUGGING 
    2016     /*GUI_MODE_DEBUG*/          { gui_debug_draw,       gui_debug_kbd_process,      gui_default_kbd_process_menu_btn }, 
    2017 #else 
    2018                                 { 0, 0, 0 }, 
    2019 #endif 
    2020     /*GUI_MODE_FSELECT*/        { gui_fselect_draw,     gui_fselect_kbd_process,    gui_fselect_kbd_process }, 
    2021 #ifdef OPT_TEXTREADER 
    2022     /*GUI_MODE_READ*/           { gui_read_draw,        gui_read_kbd_process,       gui_read_kbd_process_menu_btn }, 
    2023 #else 
    2024                                 { 0, 0, 0 }, 
    2025 #endif 
    2026     /*GUI_MODE_OSD*/            { gui_osd_draw,         gui_osd_kbd_process,        gui_default_kbd_process_menu_btn }, 
    2027 #ifdef OPT_CALENDAR 
    2028     /*GUI_MODE_CALENDAR*/       { gui_calendar_draw,    gui_calendar_kbd_process,   gui_default_kbd_process_menu_btn }, 
    2029 #else 
    2030                                 { 0, 0, 0 }, 
    2031 #endif 
    2032 #ifdef OPT_DEBUGGING 
    2033     /*GUI_MODE_BENCH*/          { gui_bench_draw,       gui_bench_kbd_process,      gui_default_kbd_process_menu_btn }, 
    2034 #else 
    2035                                 { 0, 0, 0 }, 
    2036 #endif 
    2037     /*GUI_MODE_MPOPUP*/         { gui_mpopup_draw,      gui_mpopup_kbd_process,     gui_mpopup_kbd_process }, 
    2038 #ifdef OPT_GAME_CONNECT4 
    2039     /*GUI_MODE_4WINS*/          { gui_4wins_draw,       gui_4wins_kbd_process,      gui_default_kbd_process_menu_btn }, 
    2040 #else 
    2041                                 { 0, 0, 0 }, 
    2042 #endif 
    2043 #ifdef OPT_GAME_MASTERMIND 
    2044     /*GUI_MODE_MASTERMIND*/     { gui_mastermind_draw,  gui_mastermind_kbd_process, gui_default_kbd_process_menu_btn }, 
    2045 #else 
    2046                                 { 0, 0, 0 }, 
    2047 #endif 
     1999    /*GUI_MODE_NONE*/           { gui_draw_osd,         0,                          0,                                                          0,                                                                      GUI_MODE_MAGICNUM }, 
     2000    /*GUI_MODE_ALT*/            { gui_chdk_draw,        gui_chdk_kbd_process,       gui_chdk_kbd_process_menu_btn,      0,                                                                      GUI_MODE_MAGICNUM },             
     2001    /*GUI_MODE_MENU*/           { gui_menu_draw,        gui_menu_kbd_process,       gui_menu_kbd_process_menu_btn,      0,                                                                      GUI_MODE_MAGICNUM }, 
     2002    /*GUI_MODE_MBOX*/           { gui_mbox_draw,        gui_mbox_kbd_process,       0,                                                          GUI_MODE_FLAG_NORESTORE_ON_SWITCH,      GUI_MODE_MAGICNUM }, 
     2003    /*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 
    20482004}; 
    20492005 
     
    20522008void gui_redraw() 
    20532009{ 
    2054     enum Gui_Mode gui_mode_old; 
     2010    static gui_mode_t gui_mode_prev_tick = GUI_MODE_NONE; 
     2011    gui_mode_t gui_mode_old; 
     2012 
     2013    static int flag_gui_enforce_redraw = 0; 
    20552014 
    20562015#ifdef CAM_DETECT_SCREEN_ERASE 
     
    20582017    { 
    20592018        draw_set_guard(); 
    2060         gui_menu_force_redraw(); 
    2061         gui_fselect_force_redraw(); 
     2019 
     2020                flag_gui_enforce_redraw |= GUI_REDRAWFLAG_ERASEGUARD; 
     2021        //gui_menu_force_redraw(); 
     2022        //gui_fselect_force_redraw();   //@tsv 
    20622023#ifdef CAM_TOUCHSCREEN_UI 
    20632024        extern int redraw_buttons; 
     
    20782039 
    20792040    // Call redraw handler 
    2080     if (guiHandlers[gui_mode].redraw) guiHandlers[gui_mode].redraw(); 
     2041        gui_handler* cur_gui_handler = (gui_mode<GUI_MODE_COUNT)? (&guiHandlers[gui_mode]) : (gui_handler*)gui_mode; 
     2042    if (cur_gui_handler->redraw) cur_gui_handler->redraw(flag_gui_enforce_redraw); 
     2043        flag_gui_enforce_redraw=0; 
    20812044 
    20822045    // Forced redraw if needed 
    20832046    gui_in_redraw = 0; 
    2084     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) { 
    2085         if (gui_restore) gui_menu_force_redraw(); 
     2047        cur_gui_handler = (gui_mode<GUI_MODE_COUNT)? (&guiHandlers[gui_mode]) : (gui_handler*)gui_mode; 
     2048    if ((gui_mode_old != gui_mode  
     2049                        && (gui_mode_old != GUI_MODE_NONE && gui_mode_old != GUI_MODE_ALT)  
     2050                        && !(cur_gui_handler->flags & GUI_MODE_FLAG_NORESTORE_ON_SWITCH))  
     2051            || gui_restore )  
     2052        { 
     2053 
     2054        if (gui_restore) 
     2055                        flag_gui_enforce_redraw |= GUI_REDRAWFLAG_DRAW_RESTORED; 
    20862056        gui_restore = 0; 
    2087         if (gui_mode != GUI_MODE_REVERSI && gui_mode != GUI_MODE_SOKOBAN && gui_mode != GUI_MODE_4WINS && gui_mode != GUI_MODE_MASTERMIND) 
     2057 
     2058        if ( !( cur_gui_handler->flags & GUI_MODE_FLAG_NODRAWRESTORE) ) 
    20882059            draw_restore(); 
    20892060    } 
     2061 
     2062        if ( gui_mode_prev_tick != gui_mode ) { 
     2063                flag_gui_enforce_redraw |= GUI_REDRAWFLAG_MODE_WAS_CHANGED; 
     2064                gui_mode_prev_tick = gui_mode; 
     2065        } 
    20902066} 
    20912067 
     
    20942070void gui_kbd_process() 
    20952071{ 
     2072        gui_handler* cur_gui_handler = (gui_mode<GUI_MODE_COUNT)? (&guiHandlers[gui_mode]) : (gui_handler*)gui_mode;     
     2073 
    20962074    // Call menu button handler if menu button pressed 
    20972075    if (kbd_is_key_clicked(KEY_MENU)) 
    20982076    { 
    2099         if (guiHandlers[gui_mode].kbd_process_menu_btn) guiHandlers[gui_mode].kbd_process_menu_btn(); 
     2077        if (cur_gui_handler->kbd_process_menu_btn) cur_gui_handler->kbd_process_menu_btn(); 
    21002078        return; 
    21012079    } 
    21022080 
    21032081    // Call mode handler for other buttons 
    2104     if (guiHandlers[gui_mode].kbd_process) guiHandlers[gui_mode].kbd_process(); 
     2082    if (cur_gui_handler->kbd_process) cur_gui_handler->kbd_process(); 
    21052083} 
    21062084 
     
    21422120#endif 
    21432121    draw_restore(); 
    2144     if (gui_mode == GUI_MODE_READ && !rbf_load(conf.menu_rbf_file)) 
    2145         rbf_load_from_8x16(current_font); 
    21462122    rbf_set_codepage(FONT_CP_WIN); 
    21472123    vid_turn_on_updates(); 
    21482124    gui_set_mode(GUI_MODE_NONE); 
     2125 
     2126        // Unload all modules which are marked as safe to unload 
     2127        module_async_unload_allrunned(0); 
    21492128 
    21502129        conf_update_prevent_shutdown(); 
     
    25612540//------------------------------------------------------------------- 
    25622541void gui_draw_palette(int arg) { 
    2563     draw_restore(); 
    2564     gui_palette_init(PALETTE_MODE_DEFAULT, 0x00, NULL); 
    2565     gui_set_mode(GUI_MODE_PALETTE); 
     2542    module_palette_run(PALETTE_MODE_DEFAULT, 0x00, NULL); 
    25662543} 
    25672544 
     
    26002577    } 
    26012578 
    2602     gui_set_mode(GUI_MODE_REVERSI); 
    2603     gui_reversi_init(); 
     2579    module_run("reversi.flt", 0, 0,0, UNLOAD_IF_ERR); 
    26042580} 
    26052581#endif 
     
    26132589        return; 
    26142590    } 
    2615     if ( gui_sokoban_init() ) 
    2616         gui_set_mode(GUI_MODE_SOKOBAN); 
     2591 
     2592    module_run("sokoban.flt", 0, 0,0, UNLOAD_IF_ERR); 
    26172593} 
    26182594#endif 
     
    26252601        return; 
    26262602    } 
    2627     if ( gui_4wins_init() ) 
    2628         gui_set_mode(GUI_MODE_4WINS); 
     2603 
     2604    module_run("4wins.flt", 0, 0,0, UNLOAD_IF_ERR); 
    26292605} 
    26302606#endif 
     
    26372613        return; 
    26382614    } 
    2639     if ( gui_mastermind_init() ) 
    2640         gui_set_mode(GUI_MODE_MASTERMIND); 
     2615    module_run("mastmind.flt", 0, 0,0, UNLOAD_IF_ERR); 
    26412616} 
    26422617#endif 
     
    26482623//    gui_debug_init(0x7F5B8); 
    26492624//    gui_debug_init(malloc(16)); 
    2650     gui_debug_init((void*)conf.mem_view_addr_init); 
     2625//    gui_debug_init((void*)conf.mem_view_addr_init); 
     2626 
     2627        unsigned int argv[] ={ (unsigned int)conf.mem_view_addr_init }; 
     2628    module_run("memview.flt", 0, 1,argv, UNLOAD_IF_ERR); 
     2629} 
     2630 
     2631void gui_draw_modinspector(int arg) { 
     2632    module_run("modinsp.flt", 0, 0,0, UNLOAD_IF_ERR); 
    26512633} 
    26522634 
    26532635//------------------------------------------------------------------- 
    26542636void gui_draw_bench(int arg) { 
    2655     gui_set_mode(GUI_MODE_BENCH); 
    2656     gui_bench_init(); 
     2637    module_run("benchm.flt", 0, 0,0, UNLOAD_IF_ERR); 
    26572638} 
    26582639#endif 
     
    27172698//------------------------------------------------------------------- 
    27182699void gui_draw_fselect(int arg) { 
    2719     gui_fselect_init(LANG_STR_FILE_BROWSER, "A", "A", NULL); 
     2700    module_fselect_init(LANG_STR_FILE_BROWSER, "A", "A", NULL); 
    27202701} 
    27212702 
     
    27262707} 
    27272708void gui_grid_lines_load(int arg) { 
    2728     gui_fselect_init(LANG_STR_SELECT_GRID_FILE, conf.grid_lines_file, "A/CHDK/GRIDS", gui_grid_lines_load_selected); 
     2709    module_fselect_init(LANG_STR_SELECT_GRID_FILE, conf.grid_lines_file, "A/CHDK/GRIDS", gui_grid_lines_load_selected); 
    27292710} 
    27302711 
     
    27422723            rbf_load_from_8x16(current_font); 
    27432724        rbf_set_codepage(conf.reader_codepage); 
    2744         gui_set_mode(GUI_MODE_READ); 
    2745         gui_read_init(fn); 
     2725 
     2726                unsigned int argv[] ={ (unsigned int)fn }; 
     2727                module_run("txtread.flt", 0, sizeof(argv)/sizeof(argv[0]), argv, UNLOAD_IF_ERR); 
    27462728    } 
    27472729} 
    27482730 
    27492731void gui_draw_read(int arg) { 
    2750     gui_fselect_init(LANG_STR_SELECT_TEXT_FILE, conf.reader_file, "A/CHDK/BOOKS", gui_draw_read_selected); 
     2732    module_fselect_init_w_mode(LANG_STR_SELECT_TEXT_FILE, conf.reader_file, "A/CHDK/BOOKS", gui_draw_read_selected, 1); 
    27512733    void gui_fselect_set_key_redraw(int n); 
    2752     gui_fselect_set_key_redraw(1); 
     2734    //gui_fselect_set_key_redraw(1);    @tsv 
    27532735} 
    27542736 
     
    27712753#ifdef OPT_EDGEOVERLAY 
    27722754static void gui_load_edge_selected( const char* fn ) { 
    2773     if( fn ) 
    2774         load_edge_overlay(fn); 
     2755    if( fn && module_edgeovr_load()) 
     2756                load_edge_overlay(fn); 
    27752757} 
    27762758 
    27772759void gui_menuproc_edge_save(int arg) { 
    2778     save_edge_overlay(); 
     2760        if ( module_edgeovr_load() ) 
     2761        save_edge_overlay(); 
    27792762} 
    27802763 
    27812764void gui_menuproc_edge_load(int arg) { 
    2782     gui_fselect_init(LANG_MENU_EDGE_LOAD, EDGE_SAVE_DIR, EDGE_SAVE_DIR, gui_load_edge_selected); 
     2765    module_fselect_init(LANG_MENU_EDGE_LOAD, EDGE_SAVE_DIR, EDGE_SAVE_DIR, gui_load_edge_selected); 
    27832766} 
    27842767#endif 
     
    27872770#ifdef OPT_CALENDAR 
    27882771void gui_draw_calendar(int arg) { 
    2789     gui_set_mode(GUI_MODE_CALENDAR); 
    2790     gui_calendar_init(); 
     2772        module_run("calend.flt", 0, 0,0, UNLOAD_IF_ERR); 
    27912773} 
    27922774#endif 
     
    27992781} 
    28002782void gui_draw_load_rbf(int arg) { 
    2801     gui_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.reader_rbf_file, "A/CHDK/FONTS", gui_draw_rbf_selected); 
     2783    module_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.reader_rbf_file, "A/CHDK/FONTS", gui_draw_rbf_selected); 
    28022784} 
    28032785#endif 
     
    28132795} 
    28142796void gui_draw_load_menu_rbf(int arg) { 
    2815     gui_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.menu_rbf_file, "A/CHDK/FONTS", gui_draw_menu_rbf_selected); 
     2797    module_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.menu_rbf_file, "A/CHDK/FONTS", gui_draw_menu_rbf_selected); 
    28162798} 
    28172799 
     
    28252807} 
    28262808void gui_draw_load_symbol_rbf(int arg) { 
    2827     gui_fselect_init(LANG_STR_SELECT_SYMBOL_FILE, conf.menu_symbol_rbf_file, "A/CHDK/SYMBOLS", gui_draw_symbol_rbf_selected); 
     2809    module_fselect_init(LANG_STR_SELECT_SYMBOL_FILE, conf.menu_symbol_rbf_file, "A/CHDK/SYMBOLS", gui_draw_symbol_rbf_selected); 
    28282810} 
    28292811 
     
    28372819} 
    28382820void gui_draw_load_lang(int arg) { 
    2839     gui_fselect_init(LANG_STR_SELECT_LANG_FILE, conf.lang_file, "A/CHDK/LANG", gui_draw_lang_selected); 
     2821    module_fselect_init(LANG_STR_SELECT_LANG_FILE, conf.lang_file, "A/CHDK/LANG", gui_draw_lang_selected); 
    28402822} 
    28412823 
  • branches/reyalp-flt/core/gui_4wins.c

    r1338 r1467  
    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 
     
    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} 
  • branches/reyalp-flt/core/gui_4wins.h

    r600 r1467  
    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//------------------------------------------------------------------- 
  • branches/reyalp-flt/core/gui_bench.c

    r1024 r1467  
    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//------------------------------------------------------------------- 
     
    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} 
  • branches/reyalp-flt/core/gui_calendar.c

    r1338 r1467  
    99#include "gui_lang.h" 
    1010#include "gui_calendar.h" 
     11 
     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 }; 
    1117 
    1218//------------------------------------------------------------------- 
     
    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 
     
    122132 
    123133//------------------------------------------------------------------- 
    124 void gui_calendar_draw() { 
     134void gui_calendar_draw(int enforce_redraw) { 
    125135    int x, y; 
    126136    static char str[32]; 
     
    173183} 
    174184 
     185extern int module_idx; 
     186 
     187void gui_calendar_menu_kbd_process() { 
     188        gui_default_kbd_process_menu_btn(); 
     189        module_async_unload(module_idx); 
     190} 
  • branches/reyalp-flt/core/gui_calendar.h

    r515 r1467  
    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//------------------------------------------------------------------- 
  • branches/reyalp-flt/core/gui_debug.c

    r1024 r1467  
    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 
     
    5663 
    5764//------------------------------------------------------------------- 
    58 void gui_debug_draw() { 
     65void gui_debug_draw(int enforce_redraw) { 
    5966    switch (debug_to_draw) { 
    6067        case 1: 
     
    8794            gui_debug_draw_values(2, addr); 
    8895            gui_debug_draw_values(8, *((void**)addr)); 
    89             conf.mem_view_addr_init = (long)addr; 
     96            *conf_mem_view_addr_init = (long)addr; 
    9097 
    9198            if (debug_cont_update==0) debug_to_draw = 0; 
     
    142149 
    143150//------------------------------------------------------------------- 
     151 
     152extern int module_idx; 
     153void gui_module_menu_kbd_process() { 
     154        gui_default_kbd_process_menu_btn(); 
     155        module_async_unload(module_idx); 
     156} 
     157 
     158 
     159// =========  MODULE INIT ================= 
     160#include "module_load.h" 
     161int module_idx=-1; 
     162 
     163/***************** BEGIN OF AUXILARY PART ********************* 
     164  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     165 **************************************************************/ 
     166 
     167int _chdk_required_ver = 1;                     // minimal required chdk build. 0-no limitation 
     168int _chdk_required_platfid = 0;         // platform-specific module. 0-no limitation 
     169 
     170void* MODULE_EXPORT_LIST[] = { 
     171        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     172        /* 1 */ (void*)0 
     173                }; 
     174 
     175 
     176//--------------------------------------------------------- 
     177// PURPOSE:   Bind module symbols with chdk.  
     178//              Required function 
     179// PARAMETERS: pointer to chdk list of export 
     180// RETURN VALUE: 1 error, 0 ok 
     181//--------------------------------------------------------- 
     182int _module_loader( void** chdk_export_list ) 
     183{ 
     184  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     185     return 1; 
     186 
     187  tConfigVal configVal; 
     188  CONF_BIND_INT(195, conf_mem_view_addr_init); 
     189 
     190  return 0; 
     191} 
     192 
     193 
     194 
     195//--------------------------------------------------------- 
     196// PURPOSE: Finalize module operations (close allocs, etc) 
     197// RETURN VALUE: 0-ok, 1-fail 
     198//--------------------------------------------------------- 
     199int _module_unloader() 
     200{ 
     201  return 0; 
     202} 
     203 
     204 
     205//--------------------------------------------------------- 
     206// PURPOSE: Default action for simple modules (direct run) 
     207// NOTE: Please comment this function if no default action and this library module 
     208//--------------------------------------------------------- 
     209int _module_run(int moduleidx, int argn, int* arguments) 
     210{ 
     211  module_idx=moduleidx; 
     212 
     213  if ( argn!=1) { 
     214        module_async_unload(moduleidx); 
     215    return 1; 
     216  } 
     217 
     218  void* adr=(char*)arguments[0]; 
     219  gui_debug_init(adr); 
     220 
     221  return 0; 
     222} 
     223 
     224 
     225/*************** END OF AUXILARY PART *******************/ 
  • branches/reyalp-flt/core/gui_debug.h

    r515 r1467  
    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//------------------------------------------------------------------- 
  • branches/reyalp-flt/core/gui_draw.c

    r1365 r1467  
    303303} 
    304304 
     305// Restore CANON_OSD 
    305306//------------------------------------------------------------------- 
    306307void draw_restore() { 
  • branches/reyalp-flt/core/gui_draw.h

    r1414 r1467  
    33 
    44#include        "camera.h"              // ensure the camera defintion is loaded 
     5 
     6#include "gui.h"        // for color, coord definitions 
    57 
    68//------------------------------------------------------------------- 
  • branches/reyalp-flt/core/gui_fselect.c

    r1423 r1467  
    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 =  
     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) { 
     
    117162            selected = top; 
    118163        } 
    119     } 
    120 } 
    121  
    122 //------------------------------------------------------------------- 
    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; 
    129164    } 
    130165} 
     
    305340 
    306341//------------------------------------------------------------------- 
    307 void gui_fselect_init(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn)) { 
     342void gui_fselect_init(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn))  
     343{ 
    308344    int i; 
    309345     
     
    354390    gui_fselect_mode_old = gui_get_mode(); 
    355391    gui_fselect_redraw = 2; 
    356     gui_set_mode(GUI_MODE_FSELECT); 
     392    gui_set_mode((unsigned int)&GUI_MODE_FSELECT); 
    357393    gui_fselect_set_key_redraw(0); 
    358394} 
     
    381417 
    382418//------------------------------------------------------------------- 
    383 void gui_fselect_draw() { 
     419void gui_fselect_draw(int enforce_redraw) { 
    384420    int i, j, off_name_x, off_size_x, off_time_x, off_body_x, off_body_y; 
    385421    struct fitem  *ptr; 
     
    389425    color cl_markered = ((mode_get()&MODE_MASK) == MODE_REC)?COLOR_YELLOW:0x66; 
    390426    color cl_marked, cl_selected; 
     427 
     428        if ( enforce_redraw ) 
     429                gui_fselect_redraw = 2; 
    391430 
    392431    if (gui_fselect_redraw) { 
     
    874913 
    875914//------------------------------------------------------------------- 
     915static void fselect_chdk_replace_cb(unsigned int btn) { 
     916    int ss, sd = 0, fsrc, fdst, i=0; 
     917    register int *buf; 
     918    unsigned char fend; 
     919    static struct utimbuf t; 
     920 
     921    if (btn != MBOX_BTN_YES) return; 
     922 
     923    buf = umalloc(MARKED_BUF_SIZE); 
     924    sprintf(selected_file, "%s/%s", current_dir, selected->name); 
     925    fsrc = open(selected_file, O_RDONLY, 0777); 
     926    if (fsrc>=0) { 
     927            strcpy(selected_file,"A/DISKBOOT.BIN"); 
     928            fdst = open(selected_file, O_WRONLY|O_CREAT|O_TRUNC, 0777); 
     929            if (fdst>=0) { 
     930                do { 
     931                    ss=read(fsrc, buf, MARKED_BUF_SIZE); 
     932                    if (ss>0) sd=write(fdst, buf, ss); 
     933                } while (ss>0 && ss==sd); 
     934                close(fdst); 
     935                t.actime = t.modtime = selected->mtime; 
     936                utime(selected_file, &t); 
     937                //shutdown(); 
     938                        gui_browser_progress_show("Please reboot",100); 
     939            } 
     940        if (fsrc>=0) close(fsrc); 
     941    } 
     942    ufree(buf); 
     943} 
     944 
     945//------------------------------------------------------------------- 
    876946static void fselect_marked_inverse_selection() { 
    877947    struct fitem  *ptr; 
     
    887957void process_raw_files(void){ 
    888958 struct fitem *ptr; 
    889  if ((fselect_marked_count()>1) && raw_merge_start(raw_operation)) { 
     959 
     960 librawop_p=module_rawop_load(); 
     961 if (!librawop_p) 
     962        return;         //exit if fail 
     963 
     964 if ((fselect_marked_count()>1) && librawop_p->raw_merge_start(raw_operation)) { 
    890965   for (ptr=head; ptr; ptr=ptr->next) 
    891966     if (ptr->marked && ptr->attr != 0xFF && !(ptr->attr & DOS_ATTR_DIRECTORY)) { 
    892967       sprintf(selected_file, "%s/%s", current_dir, ptr->name); 
    893        raw_merge_add_file(selected_file); 
     968       librawop_p->raw_merge_add_file(selected_file); 
    894969      } 
    895   raw_merge_end(); 
     970  librawop_p->raw_merge_end(); 
    896971  gui_fselect_read_dir(current_dir); 
    897972 } 
     
    904979    char *raw_subtract_dest; 
    905980    if (btn != MBOX_BTN_YES) return; 
     981 
     982        librawop_p=module_rawop_load(); 
     983        if (!librawop_p) 
     984                return;         //exit if fail 
    906985 
    907986    if(!(raw_subtract_from = malloc(300))) //3x full path 
     
    916995            (strcmp(ptr->name,selected->name)) != 0) { 
    917996            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]); 
     997            sprintf(raw_subtract_dest,"%s/%s%s",current_dir,img_prefixes[*conf_sub_batch_prefix],ptr->name+4); 
     998            strcpy(raw_subtract_dest + strlen(raw_subtract_dest) - 4,img_exts[*conf_sub_batch_ext]); 
    920999            // don't let users attempt to write one of the files being read 
    9211000            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); 
     1001                librawop_p->raw_subtract(raw_subtract_from,raw_subtract_sub,raw_subtract_dest); 
    9231002            } 
    9241003        } 
     
    10471126            raw_prepare_develop(buf); 
    10481127        break; 
     1128        case MPOPUP_CHDK_REPLACE: 
     1129            gui_mbox_init((int)"Replacing CHDK", (int)"Do you want to replace current CHDK with this file", 
     1130                          MBOX_TEXT_CENTER|MBOX_BTN_YES_NO|MBOX_DEF_BTN2, fselect_chdk_replace_cb); 
     1131            break; 
     1132        case MPOPUP_EDITOR: 
     1133            gui_mbox_init((int)"Editor", (int)"edit", MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 
     1134            break; 
    10491135        case MPOPUP_SUBTRACT: 
    10501136        { 
     
    10621148 
    10631149//------------------------------------------------------------------- 
    1064 static void exit_fselect(char* file) 
     1150void finalize_fselect() 
    10651151{ 
    10661152    gui_fselect_free_data(); 
    10671153    gui_fselect_marked_free_data(); 
     1154        module_rawop_unload(); 
     1155} 
     1156 
     1157static void exit_fselect(char* file) 
     1158{ 
     1159/*DOPEN(0);     
     1160DLOG_INT("gui_fselect_exit()\n",0); 
     1161DCLOSE;*/ 
     1162        finalize_fselect(); 
     1163 
    10681164    if (set_key_redraw_mode) 
    10691165    { 
     
    10741170    { 
    10751171        fselect_on_select(file); 
     1172        // if called mode will return control to filemanager - we need to redraw it 
     1173        gui_fselect_redraw = 2; 
    10761174    } 
    10771175    if (!set_key_redraw_mode) 
     
    11441242                    i |= MPOPUP_DNG_TO_CRW; 
    11451243#endif 
    1146                 gui_mpopup_init(i, fselect_mpopup_cb); 
     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 
     1270                                                  /* //This decrease visual lag before module start, but cost memory fragment 
     1271                                                        flag_after=0; 
     1272                                                        if ( module_find(name) < 0 ) { 
     1273                                                                if ( !module_load( selected_file, 0 ) ) 
     1274                                                                        break; 
     1275                                                                flag_after=2; 
     1276                                                        } 
     1277 
     1278                                                  */ 
     1279 
     1280                                exit_fselect(0); 
     1281                                                module_run(selected_file, 0, 0,0, UNLOAD_IF_ERR); 
     1282 
     1283                                                        break; 
     1284                                                } 
     1285                                        } 
     1286 
    11631287                    exit_fselect(selected_file); 
     1288                                        module_async_unload(module_idx); 
    11641289                } 
    11651290            } 
     
    11841309            // just free resource. callback called with NULL ptr 
    11851310            exit_fselect(0); 
    1186             break; 
    1187     } 
    1188 } 
    1189  
    1190 //------------------------------------------------------------------- 
     1311                        module_async_unload(module_idx); 
     1312            break; 
     1313    } 
     1314} 
     1315 
     1316 
     1317 
     1318// =========  MODULE INIT ================= 
     1319#include "module_load.h" 
     1320int module_idx=-1; 
     1321 
     1322/***************** BEGIN OF AUXILARY PART ********************* 
     1323  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     1324 **************************************************************/ 
     1325 
     1326int _chdk_required_ver = 1;             // minimal required chdk build. 0-no limitation 
     1327int _chdk_required_platfid = 0;         // platform-specific module. 0-no limitation 
     1328 
     1329void* MODULE_EXPORT_LIST[] = { 
     1330        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     1331        /* 1 */ (void*)0 
     1332                }; 
     1333 
     1334 
     1335//--------------------------------------------------------- 
     1336// PURPOSE:   Bind module symbols with chdk.  
     1337//              Required function 
     1338// PARAMETERS: pointer to chdk list of export 
     1339// RETURN VALUE: 1 error, 0 ok 
     1340//--------------------------------------------------------- 
     1341int _module_loader( void** chdk_export_list ) 
     1342{ 
     1343  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     1344     return 1; 
     1345 
     1346  tConfigVal configVal; 
     1347  CONF_BIND_INT(209, conf_sub_batch_prefix); 
     1348  CONF_BIND_INT(210, conf_sub_batch_ext); 
     1349 
     1350  return 0; 
     1351} 
     1352 
     1353 
     1354 
     1355//--------------------------------------------------------- 
     1356// PURPOSE: Finalize module operations (close allocs, etc) 
     1357// RETURN VALUE: 0-ok, 1-fail 
     1358//--------------------------------------------------------- 
     1359int _module_unloader() 
     1360{ 
     1361        finalize_fselect(); 
     1362 
     1363        GUI_MODE_FSELECT.magicnum = 0;  //sanity clean to prevent accidentaly assign/restore guimode to unloaded module  
     1364 
     1365    return 0; 
     1366} 
     1367 
     1368 
     1369//--------------------------------------------------------- 
     1370// PURPOSE: Default action for simple modules (direct run) 
     1371// NOTE: Please comment this function if no default action and this library module 
     1372//--------------------------------------------------------- 
     1373int _module_run(int moduleidx, int argn, int* arguments) 
     1374{ 
     1375  module_idx=moduleidx; 
     1376 
     1377  if ( argn!=5) { 
     1378        module_async_unload(moduleidx); 
     1379    return 1; 
     1380  } 
     1381 
     1382  // Autounloading is unsafe because it should exists to catch finalization of mpopup 
     1383  module_set_flags(module_idx, MODULE_FLAG_DISABLE_AUTOUNLOAD); 
     1384 
     1385  gui_fselect_init( arguments[0], (const char*) arguments[1], (const char*) arguments[2], (void*)arguments[3]); 
     1386  gui_fselect_set_key_redraw(arguments[4]); 
     1387   
     1388 
     1389  return 0; 
     1390} 
     1391 
     1392 
     1393/*************** END OF AUXILARY PART *******************/ 
  • branches/reyalp-flt/core/gui_fselect.h

    r1423 r1467  
    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 
  • branches/reyalp-flt/core/gui_mastermind.c

    • Property svn:eol-style set to native
    r1338 r1467  
    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 
     
    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        return gui_mastermind_init();  
     243} 
     244 
     245extern int module_idx; 
     246void gui_module_menu_kbd_process() { 
     247        gui_default_kbd_process_menu_btn(); 
     248        module_async_unload(module_idx); 
     249} 
  • branches/reyalp-flt/core/gui_mastermind.h

    • Property svn:eol-style set to native
    r649 r1467  
    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//------------------------------------------------------------------- 
  • branches/reyalp-flt/core/gui_mbox.c

    r1431 r1467  
    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} 
  • branches/reyalp-flt/core/gui_mbox.h

    r515 r1467  
    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//------------------------------------------------------------------- 
  • branches/reyalp-flt/core/gui_menu.c

    r1425 r1467  
    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) 
  • branches/reyalp-flt/core/gui_menu.h

    r1407 r1467  
    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(); 
  • branches/reyalp-flt/core/gui_mpopup.c

    r1407 r1467  
    99#include "gui_mpopup.h" 
    1010 
     11#include "module_load.h" 
     12 
     13extern int module_idx; 
     14 
     15gui_handler GUI_MODE_MPOPUP =  
     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); 
    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(actions[mpopup_actions[action]].flag); 
     114} 
     115 
     116//------------------------------------------------------------------- 
    116117void gui_mpopup_kbd_process() { 
    117118    switch (kbd_get_clicked_key() | get_jogdial_direction()) { 
     
    131132    case KEY_LEFT: 
    132133        kbd_reset_autoclicked_key(); 
    133         gui_set_mode(gui_mpopup_mode_old); 
    134         if (mpopup_on_select)  
    135             mpopup_on_select(MPOPUP_CANCEL); 
     134                exit_mpopup(MPOPUP_CANCEL);              
     135                module_async_unload(module_idx); 
    136136        break; 
    137137    case KEY_SET: 
    138138        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 } 
     139                exit_mpopup(mpopup_actions_active);              
     140                module_async_unload(module_idx); 
     141        break; 
     142    } 
     143} 
     144 
     145//------------------------------------------------------------------- 
     146 
     147// =========  MODULE INIT ================= 
     148 
     149int module_idx=-1; 
     150 
     151/***************** BEGIN OF AUXILARY PART ********************* 
     152  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     153 **************************************************************/ 
     154 
     155int _chdk_required_ver = 1;                     // minimal required chdk build. 0-no limitation 
     156int _chdk_required_platfid = 0;         // platform-specific module. 0-no limitation 
     157 
     158void* MODULE_EXPORT_LIST[] = { 
     159        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     160        /* 1 */ (void*)0 
     161                }; 
     162 
     163 
     164//--------------------------------------------------------- 
     165// PURPOSE:   Bind module symbols with chdk.  
     166//              Required function 
     167// PARAMETERS: pointer to chdk list of export 
     168// RETURN VALUE: 1 error, 0 ok 
     169//--------------------------------------------------------- 
     170int _module_loader( void** chdk_export_list ) 
     171{ 
     172  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     173     return 1; 
     174 
     175  return 0; 
     176} 
     177 
     178 
     179 
     180//--------------------------------------------------------- 
     181// PURPOSE: Finalize module operations (close allocs, etc) 
     182// RETURN VALUE: 0-ok, 1-fail 
     183//--------------------------------------------------------- 
     184int _module_unloader() 
     185{ 
     186        exit_mpopup(MPOPUP_CANCEL);              
     187 
     188        GUI_MODE_MPOPUP.magicnum = 0;   //sanity clean to prevent accidentaly assign/restore guimode to unloaded module  
     189 
     190    return 0; 
     191} 
     192 
     193 
     194//--------------------------------------------------------- 
     195// PURPOSE: Default action for simple modules (direct run) 
     196// NOTE: Please comment this function if no default action and this library module 
     197//--------------------------------------------------------- 
     198int _module_run(int moduleidx, int argn, int* arguments) 
     199{ 
     200  module_idx=moduleidx; 
     201 
     202  if ( argn!=4) { 
     203        module_async_unload(moduleidx); 
     204    return 1; 
     205  } 
     206 
     207  // Currently only old (0) mode is supported 
     208  // This is for load error if newer version is required 
     209  if (arguments[3]!=0) 
     210                return 1; 
     211 
     212  gui_mpopup_init( (struct mpopup_item*)arguments[0], (const unsigned int)arguments[1], (void*) arguments[2], arguments[3]); 
     213   
     214 
     215  return 0; 
     216} 
     217 
     218 
     219/*************** END OF AUXILARY PART *******************/ 
  • branches/reyalp-flt/core/gui_mpopup.h

    r666 r1467  
    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//------------------------------------------------------------------- 
  • branches/reyalp-flt/core/gui_osd.c

    r1350 r1467  
    105105 
    106106//------------------------------------------------------------------- 
    107 void gui_osd_draw() { 
     107void gui_osd_draw(int enforce_redraw) { 
    108108    if (osd_to_draw) { 
    109109        int i; 
  • branches/reyalp-flt/core/gui_osd.h

    r683 r1467  
    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(); 
  • branches/reyalp-flt/core/gui_palette.c

    r1338 r1467  
    1010#include "gui_palette.h" 
    1111 
     12 
     13#include "module_load.h" 
     14void gui_module_menu_kbd_process(); 
     15 
     16gui_handler GUI_MODE_PALETTE =  
     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); 
    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 
     133int _chdk_required_ver = 1;             // minimal required chdk build. 0-no limitation 
     134int _chdk_required_platfid = 0;         // platform-specific module. 0-no limitation 
     135 
     136void* MODULE_EXPORT_LIST[] = { 
     137        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     138        /* 1 */ (void*)0 
     139                }; 
     140 
     141 
     142//--------------------------------------------------------- 
     143// PURPOSE:   Bind module symbols with chdk.  
     144//              Required function 
     145// PARAMETERS: pointer to chdk list of export 
     146// RETURN VALUE: 1 error, 0 ok 
     147//--------------------------------------------------------- 
     148int _module_loader( void** chdk_export_list ) 
     149{ 
     150  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     151     return 1; 
     152 
     153  return 0; 
     154} 
     155 
     156 
     157 
     158//--------------------------------------------------------- 
     159// PURPOSE: Finalize module operations (close allocs, etc) 
     160// RETURN VALUE: 0-ok, 1-fail 
     161//--------------------------------------------------------- 
     162int _module_unloader() 
     163{ 
     164  GUI_MODE_PALETTE.magicnum = 0;        //sanity clean to prevent accidentaly assign/restore guimode to unloaded module  
     165 
     166  return 0; 
     167} 
     168 
     169 
     170//--------------------------------------------------------- 
     171// PURPOSE: Default action for simple modules (direct run) 
     172// NOTE: Please comment this function if no default action and this library module 
     173//--------------------------------------------------------- 
     174int _module_run(int moduleidx, int argn, int* arguments) 
     175{ 
     176  module_idx=moduleidx; 
     177 
     178  if ( argn!=3) { 
     179        module_async_unload(moduleidx); 
     180    return 1; 
     181  } 
     182 
     183  gui_palette_init( arguments[0], (color)arguments[1], (void*)arguments[2]); 
     184 
     185  return 0; 
     186} 
     187 
     188 
     189/*************** END OF AUXILARY PART *******************/ 
  • branches/reyalp-flt/core/gui_palette.h

    r515 r1467  
    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//------------------------------------------------------------------- 
  • branches/reyalp-flt/core/gui_read.c

    r1338 r1467  
    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 
     
    4967    static struct stat   st; 
    5068    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); 
     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; 
    5674    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; 
     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 
     283int _chdk_required_ver = 1;             // minimal required chdk build. 0-no limitation 
     284int _chdk_required_platfid = 0;         // platform-specific module. 0-no limitation 
     285 
     286void* MODULE_EXPORT_LIST[] = { 
     287        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     288        /* 1 */ (void*)0 
     289                }; 
     290 
     291 
     292//--------------------------------------------------------- 
     293// PURPOSE:   Bind module symbols with chdk.  
     294//              Required function 
     295// PARAMETERS: pointer to chdk list of export 
     296// RETURN VALUE: 1 error, 0 ok 
     297//--------------------------------------------------------- 
     298int _module_loader( void** chdk_export_list ) 
     299{ 
     300  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     301     return 1; 
     302 
     303  tConfigVal configVal; 
     304  CONF_BIND_COLOR( 31, conf_reader_color          ); 
     305  CONF_BIND_STR( 38, conf_reader_file             ); 
     306  CONF_BIND_INT( 39, conf_reader_pos              ); 
     307  CONF_BIND_INT( 43, conf_reader_autoscroll       ); 
     308  CONF_BIND_INT( 44, conf_reader_autoscroll_delay ); 
     309  CONF_BIND_INT( 61, conf_reader_wrap_by_words    ); 
     310  CONF_BIND_STR( 66, conf_menu_rbf_file           ); 
     311 
     312  return 0; 
     313} 
     314 
     315 
     316 
     317//--------------------------------------------------------- 
     318// PURPOSE: Finalize module operations (close allocs, etc) 
     319// RETURN VALUE: 0-ok, 1-fail 
     320//--------------------------------------------------------- 
     321int _module_unloader() 
     322{ 
     323  // We should make "leave sequence" to restore font settings 
     324  gui_read_kbd_leave(); 
     325 
     326  GUI_MODE_READ.magicnum = 0;   //sanity clean to prevent accidentaly assign/restore guimode to unloaded module  
     327 
     328  return 0; 
     329} 
     330 
     331 
     332//--------------------------------------------------------- 
     333// PURPOSE: Default action for simple modules (direct run) 
     334// NOTE: Please comment this function if no default action and this library module 
     335//--------------------------------------------------------- 
     336int _module_run(int moduleidx, int argn, int* arguments) 
     337{ 
     338  module_idx=moduleidx; 
     339 
     340  if ( argn!=1 || arguments[0]==0) { 
     341        module_async_unload(moduleidx); 
     342    return 1; 
     343  } 
     344 
     345  char* fn=(char*)arguments[0]; 
     346  gui_read_init(fn); 
     347 
     348  return 0; 
     349} 
     350 
     351 
     352/*************** END OF AUXILARY PART *******************/ 
  • branches/reyalp-flt/core/gui_read.h

    r515 r1467  
    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//------------------------------------------------------------------- 
  • branches/reyalp-flt/core/gui_reversi.c

    r1338 r1467  
    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 
     
    397406 
    398407//------------------------------------------------------------------- 
    399 void gui_reversi_draw() { 
     408void gui_reversi_draw(int enforce_redraw) { 
    400409    if (need_redraw_all) { 
    401410        need_redraw_all = 0; 
     
    415424} 
    416425 
     426 
     427extern int module_idx; 
     428void gui_module_menu_kbd_process() { 
     429        gui_default_kbd_process_menu_btn(); 
     430        module_async_unload(module_idx); 
     431} 
  • branches/reyalp-flt/core/gui_reversi.h

    r515 r1467  
    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//------------------------------------------------------------------- 
  • branches/reyalp-flt/core/gui_sokoban.c

    r1338 r1467  
    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} 
     
    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} 
     
    363374        case KEY_DISPLAY: 
    364375      #endif 
    365             sokoban_set_level(conf.sokoban_level); 
     376            sokoban_set_level(*conf_sokoban_level); 
    366377            need_redraw_all = 1; 
    367378            break; 
     
    376387 
    377388//------------------------------------------------------------------- 
    378 void gui_sokoban_draw() { 
     389void gui_sokoban_draw(int enforce_redraw) { 
    379390    int y, x; 
    380391    static char str[16]; 
     
    420431        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); 
    421432 
    422         sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_LEVEL), conf.sokoban_level+1); 
     433        sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_LEVEL), *conf_sokoban_level+1); 
    423434        draw_string(CAM_TS_BUTTON_BORDER+cell_size*FIELD_WIDTH+2, 8, str, MAKE_COLOR(SCREEN_COLOR, COLOR_WHITE)); 
    424435        sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_MOVES), moves); 
     
    437448} 
    438449 
     450 
     451extern int module_idx; 
     452void gui_module_menu_kbd_process() { 
     453        gui_default_kbd_process_menu_btn(); 
     454        module_async_unload(module_idx); 
     455} 
     456 
     457 
     458// =========  MODULE INIT ================= 
     459#include "module_load.h" 
     460int module_idx=-1; 
     461 
     462/***************** BEGIN OF AUXILARY PART ********************* 
     463  ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 
     464 **************************************************************/ 
     465 
     466int _chdk_required_ver = 1;             // minimal required chdk build. 0-no limitation 
     467int _chdk_required_platfid = 0;         // platform-specific module. 0-no limitation 
     468 
     469void* MODULE_EXPORT_LIST[] = { 
     470        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     471        /* 1 */ (void*)0 
     472                }; 
     473 
     474 
     475//--------------------------------------------------------- 
     476// PURPOSE:   Bind module symbols with chdk.  
     477//              Required function 
     478// PARAMETERS: pointer to chdk list of export 
     479// RETURN VALUE: 1 error, 0 ok 
     480//--------------------------------------------------------- 
     481int _module_loader( void** chdk_export_list ) 
     482{ 
     483  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     484     return 1; 
     485 
     486  // Safe bind of conf. 
     487  tConfigVal configVal; 
     488  CONF_BIND_INT(40, conf_sokoban_level ); 
     489 
     490  return 0; 
     491} 
     492 
     493 
     494 
     495//--------------------------------------------------------- 
     496// PURPOSE: Finalize module operations (close allocs, etc) 
     497// RETURN VALUE: 0-ok, 1-fail 
     498//--------------------------------------------------------- 
     499int _module_unloader() 
     500{ 
     501  return 0; 
     502} 
     503 
     504 
     505//--------------------------------------------------------- 
     506// PURPOSE: Default action for simple modules (direct run) 
     507// NOTE: Please comment this function if no default action and this library module 
     508//--------------------------------------------------------- 
     509int _module_run(int moduleidx, int argn, int* arguments) 
     510{ 
     511  module_idx=moduleidx; 
     512 
     513  int rv = gui_sokoban_init(); 
     514  if ( ! rv ) 
     515        module_async_unload(moduleidx);         // fail to init - "unload me" 
     516 
     517  return 0; 
     518} 
     519 
     520 
     521/*************** END OF AUXILARY PART *******************/ 
  • branches/reyalp-flt/core/gui_sokoban.h

    r522 r1467  
    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//------------------------------------------------------------------- 
  • branches/reyalp-flt/core/kbd.c

    r1464 r1467  
    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) { 
     
    267279                // Note: this is blocked if CHDK is in the file selector. prevents problems 
    268280                //       when the file selector is called from a script. 
    269         if (kbd_is_key_pressed(KEY_SHOOT_FULL) && (gui_get_mode() != GUI_MODE_FSELECT) && (gui_get_mode() != GUI_MODE_MPOPUP)) { 
     281        // TODO selelect and popup checks temp disabled for module work 
     282        if (kbd_is_key_pressed(KEY_SHOOT_FULL)/* && (gui_get_mode() != GUI_MODE_FSELECT) && (gui_get_mode() != GUI_MODE_MPOPUP)*/) { 
    270283            key_pressed = 100; 
    271284            if (!state_kbd_script_run) { 
  • branches/reyalp-flt/core/luascript.c

    r1452 r1467  
    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" 
     
    126126void lua_script_reset() 
    127127{ 
     128  module_rawop_unload(); 
    128129  lua_close( L ); 
    129130  L = 0; 
     
    267268  int value; 
    268269  value=luaL_checknumber( L, 1 ); 
     270  if (module_curve_load()) 
     271    return luaL_argerror(L,1,"fail to load curves module"); 
    269272  curve_set_mode(value); 
    270273  return 0; 
     
    817820    // the Func/Set key again will enter the Script menu, not the File Browser 
    818821    kbd_reset_autoclicked_key(); 
     822 
     823        lua_pushstring( Lt, (fn && fn[0])? fn : NULL ); 
     824 
    819825} 
    820826 
     
    825831    action_push(AS_FILE_BROWSER); 
    826832    // Switch to file browser gui mode. Path can be supplied in call or defaults to "A" (root directory). 
    827     gui_fselect_init(LANG_STR_FILE_BROWSER, luaL_optstring( L, 1, "A" ), "A", file_browser_selected); 
     833    module_fselect_init(LANG_STR_FILE_BROWSER, luaL_optstring( L, 1, "A" ), "A", file_browser_selected); 
    828834    // Yield the script so that the action stack will process the AS_FILE_BROWSER action 
    829835    return lua_yield(L, 0); 
     
    12371243{ 
    12381244  int op = luaL_checknumber(L,1); 
     1245  if (!module_rawop_load()) 
     1246    return luaL_argerror(L,1,"fail to load raw merge module"); 
    12391247  if (op == RAW_OPERATION_SUM || op == RAW_OPERATION_AVERAGE) { 
    1240     raw_merge_start(op); 
     1248    librawop.raw_merge_start(op); 
    12411249  } 
    12421250  else { 
     
    12491257static int luaCB_raw_merge_add_file( lua_State* L ) 
    12501258{ 
    1251   raw_merge_add_file(luaL_checkstring( L, 1 )); 
     1259  if (!module_rawop_load()) 
     1260    return luaL_argerror(L,1,"fail to load raw merge module"); 
     1261  librawop.raw_merge_add_file(luaL_checkstring( L, 1 )); 
    12521262  return 0; 
    12531263} 
     
    12551265static int luaCB_raw_merge_end( lua_State* L ) 
    12561266{ 
    1257   raw_merge_end(); 
     1267  if (!module_rawop_load()) 
     1268    return luaL_argerror(L,1,"fail to load raw merge module"); 
     1269  librawop.raw_merge_end(); 
    12581270  return 0; 
    12591271} 
  • branches/reyalp-flt/core/main.c

    r1441 r1467  
    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 
     
    180185 
    181186            histogram_process(); 
     187 
     188 
    182189#ifdef OPT_EDGEOVERLAY 
    183             if(conf.edge_overlay_thresh && conf.edge_overlay_enable) edge_overlay(); 
     190            if(conf.edge_overlay_thresh && conf.edge_overlay_enable) { 
     191 
     192                                // We need to skip first tick because stability 
     193                                static int skip_counter=1; 
     194                                 
     195                                if (skip_counter>0) { 
     196                                        skip_counter--; 
     197                                } 
     198                                else if (module_edgeovr_load()) { 
     199                                        edge_overlay(); 
     200                                } 
     201                        } 
    184202#endif 
    185203        } 
     
    190208        } 
    191209 
     210                // Process async module unload requests 
     211                module_tick_unloader(); 
     212 
    192213        msleep(20); 
    193214    } 
  • branches/reyalp-flt/core/raw.c

    r1414 r1467  
    1414#endif 
    1515#ifdef OPT_CURVES 
    16     #include "curves.h" 
     16    #include "modules.h" 
    1717#endif 
    1818#include "shot_histogram.h" 
     
    181181        } 
    182182#ifdef OPT_CURVES 
    183         if (conf.curve_enable) curve_apply(); 
     183        if (conf.curve_enable) { 
     184                        if (module_curve_load()) 
     185                                curve_apply(); 
     186                } 
    184187#endif 
    185188        finished(); 
     
    297300 
    298301#ifdef OPT_CURVES 
    299     if (conf.curve_enable) curve_apply(); 
     302    if (conf.curve_enable) { 
     303                if (module_curve_load()) 
     304                        curve_apply(); 
     305        } 
    300306#endif 
    301307    return ret; 
  • branches/reyalp-flt/core/raw_merge.c

    r1211 r1467  
    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 
     
    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); 
     
    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 
     381int _chdk_required_ver = 1;             // minimal required chdk build. 0-no limitation 
     382int _chdk_required_platfid = 0;         // platform-specific module. 0-no limitation 
     383 
     384void* MODULE_EXPORT_LIST[] = { 
     385        /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 
     386        /* 1 */ (void*)6, 
     387 
     388                        raw_merge_start, 
     389                        raw_merge_add_file, 
     390                        raw_merge_end, 
     391                        raw_subtract 
     392                }; 
     393 
     394 
     395//--------------------------------------------------------- 
     396// PURPOSE:   Bind module symbols with chdk.  
     397//              Required function 
     398// PARAMETERS: pointer to chdk list of export 
     399// RETURN VALUE: 1 error, 0 ok 
     400//--------------------------------------------------------- 
     401int _module_loader( void** chdk_export_list ) 
     402{ 
     403  if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 
     404     return 1; 
     405 
     406  return 0; 
     407} 
     408 
     409 
     410 
     411//--------------------------------------------------------- 
     412// PURPOSE: Finalize module operations (close allocs, etc) 
     413// RETURN VALUE: 0-ok, 1-fail 
     414//--------------------------------------------------------- 
     415int _module_unloader() 
     416{ 
     417  return 0; 
     418} 
     419 
     420 
     421 
     422/*************** END OF AUXILARY PART *******************/ 
  • branches/reyalp-flt/core/raw_merge.h

    r594 r1467  
    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 
  • branches/reyalp-flt/core/script.c

    r1437 r1467  
    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 
  • branches/reyalp-flt/include/gui.h

    r1338 r1467  
    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, 
    1313    GUI_MODE_MENU, 
    14     GUI_MODE_PALETTE, 
    1514    GUI_MODE_MBOX, 
    16     GUI_MODE_REVERSI, 
    17     GUI_MODE_SOKOBAN, 
    18     GUI_MODE_DEBUG, 
    19     GUI_MODE_FSELECT, 
    20     GUI_MODE_READ, 
    2115    GUI_MODE_OSD, 
    22     GUI_MODE_CALENDAR, 
    23     GUI_MODE_BENCH, 
    24     GUI_MODE_MPOPUP, 
    25     GUI_MODE_4WINS, 
    26     GUI_MODE_MASTERMIND 
     16        GUI_MODE_COUNT 
    2717}; 
     18 
     19typedef unsigned int gui_mode_t; 
     20 
     21#define GUI_MODE_MAGICNUM       0xd36c1559 
     22 
     23// Specific behaviour of gui mode 
     24#define GUI_MODE_FLAG_NODRAWRESTORE       1 
     25#define GUI_MODE_FLAG_NORESTORE_ON_SWITCH 2 
     26 
     27 
     28// Values (bit-flag) for gui_draw argument 
     29#define GUI_REDRAWFLAG_ERASEGUARD       1 
     30#define GUI_REDRAWFLAG_MODE_WAS_CHANGED 2 
     31#define GUI_REDRAWFLAG_DRAW_RESTORED    4 
     32 
     33// Structure to store gui redraw and kbd process handlers for each mode 
     34typedef struct 
     35{ 
     36    void (*redraw)(int);                    // Called to redraw screen 
     37    void (*kbd_process)(void);              // Main button handler for mode 
     38    void (*kbd_process_menu_btn)(void);     // Menu button handler for mode 
     39        int flags; 
     40        unsigned int magicnum;                                  // Safety check for modules 
     41} gui_handler; 
     42 
     43void gui_default_kbd_process_menu_btn(); 
     44 
    2845 
    2946extern void gui_redraw(); 
     
    3249extern void draw_pixel(coord x, coord y, color cl); 
    3350 
    34 extern enum Gui_Mode gui_get_mode(); 
    35 extern void gui_set_mode(enum Gui_Mode mode); 
     51extern gui_mode_t gui_get_mode(); 
     52extern void gui_set_mode(gui_mode_t mode); 
     53 
     54 
    3655 
    3756#ifdef OPT_SCRIPTING 
  • branches/reyalp-flt/platform/g10/sub/102a/boot.c

    r1329 r1467  
    1919extern volatile int jogdial_stopped; 
    2020void JogDial_task_my(void); 
    21  
    22 enum Gui_Mode gui_get_mode() ; 
    2321 
    2422void __attribute__((naked,noinline)) task_blinker() { 
  • branches/reyalp-flt/platform/g10/sub/103b/boot.c

    r1329 r1467  
    1919extern volatile int jogdial_stopped; 
    2020void JogDial_task_my(void); 
    21  
    22 enum Gui_Mode gui_get_mode() ; 
    2321 
    2422void __attribute__((naked,noinline)) task_blinker() { 
  • branches/reyalp-flt/platform/g10/sub/104a/boot.c

    r1329 r1467  
    1919extern volatile int jogdial_stopped; 
    2020void JogDial_task_my(void); 
    21  
    22 enum Gui_Mode gui_get_mode() ; 
    2321 
    2422void __attribute__((naked,noinline)) task_blinker() { 
  • branches/reyalp-flt/platform/s95/kbd.c

    r1344 r1467  
    224224 
    225225 
     226volatile int kbd_KEY_RING_FUNC; 
     227 
    226228void my_kbd_read_keys() 
    227229{ 
     
    233235 
    234236        _GetKbdState(kbd_new_state); 
     237kbd_KEY_RING_FUNC = !(kbd_new_state[2]&0x4000); 
     238 
    235239 
    236240        if (kbd_process() == 0) { 
  • branches/reyalp-flt/tools/Makefile

    r1395 r1467  
    44 
    55include $(topdir)makefile.inc 
     6include $(topdir)version.inc 
    67 
    78OBJS=pakwif.o finsig_$(PLATFORMOS).o gensig_$(PLATFORMOS).o dumpchk.o dancingbits.o rawconvert.o dumputil.o find_levent.o find_eventproc.o yuvconvert.o font_8x16_pack.o makelang.o 
     
    1112endif 
    1213 
    13 all: pakwif$(EXE) finsig_$(PLATFORMOS)$(EXE) dancingbits$(EXE) font_8x16_pack$(EXE) makelang$(EXE) 
     14SUBDIRS+=elf2flt 
     15 
     16 
     17all: makeexport$(EXE) pakwif$(EXE) finsig_$(PLATFORMOS)$(EXE) dancingbits$(EXE) font_8x16_pack$(EXE) makelang$(EXE) 
    1418 
    1519# not needed by batch builds, not built by default 
     
    1822%.o: %.c 
    1923        @echo $< \-\> $@ 
    20         $(HOSTCC) $(HOSTCFLAGS) -DPLATFORMOS_$(PLATFORMOS) -c -o $@ $< 
     24        $(HOSTCC) $(HOSTCFLAGS) -DPLATFORMOS_$(PLATFORMOS) -DBUILD_NUMBER=\"$(BUILD_NUMBER)\" -c -o $@ $< 
    2125 
    2226.dep/%.d: %.c .dep 
     
    2428            sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ 
    2529            rm -f $@.$$$$ 
     30 
     31makeexport$(EXE): makeexport.o 
     32        @echo $< \-\> $@ 
     33        $(HOSTCC) $(HOSTCFLAGS) -o $@ $^ 
    2634 
    2735pakwif$(EXE): pakwif.o 
     
    7078 
    7179clean: 
    72         rm -f pakwif$(EXE) $(OBJS) 
     80        rm -f pakwif$(EXE) $(OBJS) makeexport.o 
    7381#       if [ -s sig_ref_vxworks_1.bin ] && [ -s sig_ref_vxworks_2.bin ] && [ -s sig_ref_vxworks_3.bin ] ; then \ 
    7482#         rm -f signatures_vxworks.h ; \ 
Note: See TracChangeset for help on using the changeset viewer.