Changeset 1505
- Timestamp:
- 12/26/11 01:24:43 (18 months ago)
- Location:
- trunk
- Files:
-
- 55 edited
- 28 copied
-
. (modified) (1 prop)
-
CHDK/MODULES (copied) (copied from branches/reyalp-flt/CHDK/MODULES)
-
CHDK/Makefile (modified) (1 diff)
-
Makefile (modified) (4 diffs)
-
buildconf.inc (modified) (1 diff)
-
core/Makefile (modified) (3 diffs)
-
core/curves.c (modified) (10 diffs)
-
core/curves.h (modified) (1 diff)
-
core/edgeoverlay.c (modified) (26 diffs)
-
core/edgeoverlay.h (modified) (1 diff)
-
core/gui.c (modified) (39 diffs)
-
core/gui_4wins.c (modified) (5 diffs)
-
core/gui_4wins.h (modified) (1 diff)
-
core/gui_bench.c (modified) (7 diffs)
-
core/gui_calendar.c (modified) (6 diffs)
-
core/gui_calendar.h (modified) (1 diff)
-
core/gui_debug.c (modified) (6 diffs)
-
core/gui_debug.h (modified) (1 diff)
-
core/gui_draw.c (modified) (1 diff)
-
core/gui_draw.h (modified) (2 diffs)
-
core/gui_fselect.c (modified) (36 diffs)
-
core/gui_fselect.h (modified) (1 diff)
-
core/gui_mastermind.c (modified) (5 diffs, 1 prop)
-
core/gui_mastermind.h (modified) (1 diff, 1 prop)
-
core/gui_mbox.c (modified) (3 diffs)
-
core/gui_mbox.h (modified) (1 diff)
-
core/gui_menu.c (modified) (4 diffs)
-
core/gui_menu.h (modified) (2 diffs)
-
core/gui_mpopup.c (modified) (6 diffs)
-
core/gui_mpopup.h (modified) (1 diff)
-
core/gui_osd.c (modified) (1 diff)
-
core/gui_osd.h (modified) (1 diff)
-
core/gui_palette.c (modified) (5 diffs)
-
core/gui_palette.h (modified) (1 diff)
-
core/gui_read.c (modified) (15 diffs)
-
core/gui_read.h (modified) (1 diff)
-
core/gui_reversi.c (modified) (5 diffs)
-
core/gui_reversi.h (modified) (1 diff)
-
core/gui_snake.c (copied) (copied from branches/reyalp-flt/core/gui_snake.c) (3 diffs)
-
core/gui_sokoban.c (modified) (9 diffs)
-
core/gui_sokoban.h (modified) (1 diff)
-
core/gui_tetris.c (copied) (copied from branches/reyalp-flt/core/gui_tetris.c) (3 diffs)
-
core/kbd.c (modified) (2 diffs)
-
core/luascript.c (modified) (8 diffs)
-
core/main.c (modified) (4 diffs)
-
core/module_exportlist.c (copied) (copied from branches/reyalp-flt/core/module_exportlist.c) (10 diffs)
-
core/module_load.c (copied) (copied from branches/reyalp-flt/core/module_load.c) (8 diffs)
-
core/module_load.h (copied) (copied from branches/reyalp-flt/core/module_load.h) (3 diffs)
-
core/module_wrappers.c (copied) (copied from branches/reyalp-flt/core/module_wrappers.c) (2 diffs)
-
core/modules (copied) (copied from branches/reyalp-flt/core/modules)
-
core/modules.c (copied) (copied from branches/reyalp-flt/core/modules.c) (3 diffs)
-
core/modules.h (copied) (copied from branches/reyalp-flt/core/modules.h) (1 diff)
-
core/modules/Makefile (copied) (copied from branches/reyalp-flt/core/modules/Makefile) (4 diffs)
-
core/modules/module_inspector.c (copied) (copied from branches/reyalp-flt/core/modules/module_inspector.c) (3 diffs)
-
core/modules/module_menu.c (copied) (copied from branches/reyalp-flt/core/modules/module_menu.c) (4 diffs)
-
core/modules/simple_game.c (copied) (copied from branches/reyalp-flt/core/modules/simple_game.c)
-
core/modules/simple_module.c (copied) (copied from branches/reyalp-flt/core/modules/simple_module.c) (1 diff)
-
core/raw.c (modified) (3 diffs)
-
core/raw_merge.c (modified) (16 diffs)
-
core/raw_merge.h (modified) (2 diffs)
-
core/script.c (modified) (1 diff)
-
include/gui.h (modified) (4 diffs)
-
include/lang.h (modified) (1 diff)
-
include/stdlib.h (modified) (2 diffs)
-
include/stdlib_unified.h (copied) (copied from branches/reyalp-flt/include/stdlib_unified.h) (1 diff)
-
lib/lang/lang.c (modified) (7 diffs)
-
platform/g10/sub/102a/boot.c (modified) (1 diff)
-
platform/g10/sub/103b/boot.c (modified) (1 diff)
-
platform/g10/sub/104a/boot.c (modified) (1 diff)
-
platform/s95/kbd.c (modified) (2 diffs)
-
tools/Makefile (modified) (5 diffs)
-
tools/elf2flt (copied) (copied from branches/reyalp-flt/tools/elf2flt)
-
tools/elf2flt/Makefile (copied) (copied from branches/reyalp-flt/tools/elf2flt/Makefile)
-
tools/elf2flt/elf-arm.c (copied) (copied from branches/reyalp-flt/tools/elf2flt/elf-arm.c) (6 diffs)
-
tools/elf2flt/elf.h (copied) (copied from branches/reyalp-flt/tools/elf2flt/elf.h) (1 diff)
-
tools/elf2flt/elfflt.c (copied) (copied from branches/reyalp-flt/tools/elf2flt/elfflt.c) (5 diffs)
-
tools/elf2flt/elfflt.h (copied) (copied from branches/reyalp-flt/tools/elf2flt/elfflt.h) (1 diff)
-
tools/elf2flt/flt.h (copied) (copied from branches/reyalp-flt/tools/elf2flt/flt.h) (5 diffs)
-
tools/elf2flt/fltdump.c (copied) (copied from branches/reyalp-flt/tools/elf2flt/fltdump.c) (6 diffs)
-
tools/elf2flt/main.c (copied) (copied from branches/reyalp-flt/tools/elf2flt/main.c)
-
tools/elf2flt/myio.c (copied) (copied from branches/reyalp-flt/tools/elf2flt/myio.c) (1 diff)
-
tools/elf2flt/myio.h (copied) (copied from branches/reyalp-flt/tools/elf2flt/myio.h)
-
tools/makeexport.c (copied) (copied from branches/reyalp-flt/tools/makeexport.c) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/reyalp-flt (added) merged: 1467,1471-1477,1481,1483,1488-1489,1493-1495,1498
- Property svn:mergeinfo changed
-
trunk/CHDK/Makefile
r1007 r1505 28 28 clean: 29 29 rm -f $(GENLUA) 30 rm -f MODULES/*.flt 30 31 31 32 include $(topdir)bottom.inc -
trunk/Makefile
r1487 r1505 11 11 firsub: all 12 12 mkdir -p $(topdir)bin 13 mkdir -p $(topdir)CHDK/MODULES 13 14 cp $(topdir)loader/$(PLATFORM)/main.bin $(topdir)bin/main.bin 14 15 ifndef NOZERO100K … … 42 43 mv $(topdir)bin/main.bin $(topdir)bin/DISKBOOT.BIN 43 44 endif 45 rm -f $(topdir)CHDK/MODULES/* 46 cp $(topdir)core/modules/*.flt $(topdir)CHDK/MODULES 44 47 @echo "**** Firmware creation completed successfully" 45 48 … … 81 84 endif 82 85 endif 86 zip -9 $(topdir)bin/$(VER)-$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)CHDK/MODULES/* 83 87 # if COPY_TO is defined then copy this camera/firmware version to the copied firmware version 84 88 # Define COPY_TO in $(topdir)/platform/$(PLATFORM)/sub/$(PLATFORMSUB)/makefile.inc of the source … … 125 129 zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)doc/readme.txt > $(DEVNULL) 126 130 zip -9j $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)doc/readme.txt > $(DEVNULL) 131 zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)-full$(STATE).zip $(topdir)CHDK/MODULES/* > $(DEVNULL) 132 zip -9 $(topdir)bin/$(PLATFORM)-$(PLATFORMSUB)-$(BUILD_NUMBER)$(STATE).zip $(topdir)CHDK/MODULES/* > $(DEVNULL) 127 133 128 134 ifdef PLATFORMOS -
trunk/buildconf.inc
r1395 r1505 1 1 #!build time optional components - comment out the features you dont want to have in your build or copy this file to localbuildconf.inc and override settings there 2 2 3 OPT_GAME_REVERSI=14 OPT_GAME_SOKOBAN=15 OPT_GAME_CONNECT4=16 OPT_GAME_MASTERMIND=17 3 OPT_CURVES=1 8 4 OPT_TEXTREADER=1 9 OPT_CALENDAR=110 5 OPT_DEBUGGING=1 11 6 OPT_EDGEOVERLAY=1 -
trunk/core/Makefile
r1465 r1505 10 10 LDOPTS+=-Wl,-N,-Ttext,$(MEMISOSTART) 11 11 12 SUBDIRS=modules 13 12 14 all: main.bin 13 15 16 # Core CHDK flag 17 CFLAGS+=-DTHIS_IS_CHDK_CORE 18 14 19 OPT_OBJS= 15 ifdef OPT_GAME_REVERSI16 CFLAGS+=-DOPT_GAME_REVERSI17 OPT_OBJS+=gui_reversi.o18 endif19 ifdef OPT_GAME_SOKOBAN20 CFLAGS+=-DOPT_GAME_SOKOBAN21 OPT_OBJS+=gui_sokoban.o22 endif23 ifdef OPT_GAME_CONNECT424 CFLAGS+=-DOPT_GAME_CONNECT425 OPT_OBJS+=gui_4wins.o26 endif27 ifdef OPT_GAME_MASTERMIND28 CFLAGS+=-DOPT_GAME_MASTERMIND29 OPT_OBJS+=gui_mastermind.o30 endif31 20 ifdef OPT_CURVES 32 21 CFLAGS+=-DOPT_CURVES 33 OPT_OBJS+=curves.o22 #OPT_OBJS+=curves.o 34 23 endif 35 24 ifdef OPT_TEXTREADER 36 25 CFLAGS+=-DOPT_TEXTREADER 37 OPT_OBJS+=gui_read.o 38 endif 39 ifdef OPT_CALENDAR 40 CFLAGS+=-DOPT_CALENDAR 41 OPT_OBJS+=gui_calendar.o 26 #OPT_OBJS+=gui_read.o 42 27 endif 43 28 ifdef OPT_DEBUGGING 44 29 # global in root makefile.inc 45 30 #CFLAGS+=-DOPT_DEBUGGING 46 OPT_OBJS+=gui_debug.o gui_bench.o31 #OPT_OBJS+=gui_debug.o gui_bench.o 47 32 endif 48 33 ifdef OPT_EDGEOVERLAY 49 34 CFLAGS+=-DOPT_EDGEOVERLAY 50 OPT_OBJS+=edgeoverlay.o35 #OPT_OBJS+=edgeoverlay.o 51 36 endif 52 37 ifdef OPT_MD_DEBUG … … 72 57 endif 73 58 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 \59 OBJS=entry.o main.o gui_draw.o gui_menu.o gui_mbox.o \ 60 gui.o kbd.o action_stack.o conf.o module_wrappers.o module_exportlist.o \ 76 61 histogram.o gui_batt.o gui_space.o gui_osd.o raw.o \ 77 gui_usb.o gui_lang.o gui_ mpopup.o gui_grid.o raw_merge.o\62 gui_usb.o gui_lang.o gui_grid.o modules.o module_load.o\ 78 63 levent.o shot_histogram.o dng.o bitvector.o console.o $(OPT_OBJS) 79 64 … … 113 98 rm -f $(OBJS:.o=.d) 114 99 100 module_load.o: module_load.c module_load.h module_exportlist.c module_exportlist.h flt.h 101 102 module_exportlist.h: $(topdir)tools/makeexport$(EXE) module_exportlist.c 103 @echo $< \-\> $@ 104 $(topdir)tools/makeexport$(EXE) module_exportlist.c module_exportlist.h modules/exportlist.txt 105 106 flt.h: $(topdir)tools/elf2flt/flt.h 107 @echo $< \-\> $@ 108 @echo "//DO NOT EDIT THIS FILE. This is automatic copy of tools/elf2flt/flt.h" > flt.h 109 cat $(topdir)tools/elf2flt/flt.h >>flt.h 110 115 111 gui_lang.o: gui_lang.c gui_lang.h gui_lang_str.h 116 112 -
trunk/core/curves.c
r727 r1505 4 4 #include "raw.h" 5 5 6 #ifdef OPT_CURVES 7 6 //#ifdef OPT_CURVES 7 #if 1 8 9 #include "module_exportlist.h" 8 10 #include "curves.h" 11 12 char *conf_curve_file; 13 int *conf_curve_enable; 9 14 10 15 /* … … 101 106 102 107 void curve_set_mode(int value) { 103 if((value>=0) && (value<=4)) conf.curve_enable=value;108 if((value>=0) && (value<=4)) *conf_curve_enable=value; 104 109 curve_init_mode(); 105 110 } 106 111 107 112 void curve_init_mode() { 108 switch( conf.curve_enable) {113 switch(*conf_curve_enable) { 109 114 case 1: // custom - ensure alloc and load conf.curve_file 110 curve_load_data(conf .curve_file,CURVE_CUSTOM);115 curve_load_data(conf_curve_file,CURVE_CUSTOM); 111 116 break; 112 117 case 2: // system - ensure alloc and load syscurve … … 116 121 break; 117 122 default: 118 conf.curve_enable = 0;123 *conf_curve_enable = 0; 119 124 case 0: // disabled - free 120 125 curve_free_data(); … … 141 146 142 147 // Loop through picture rows 143 for (i=CAM_ RAW_ROWS; i;i-=2){148 for (i=CAM_CHDK_RAW_ROWS; i;i-=2){ 144 149 // Loop through picture columns 145 for (j=CAM_ RAW_ROWPIX; j; j-=8, src+=10){150 for (j=CAM_CHDK_RAW_ROWPIX; j; j-=8, src+=10){ 146 151 pixVal0=((0x3fc&(((unsigned short)(src[1]))<<2)) | (src[0] >> 6)); 147 152 pixVal1=((0x3f0&(((unsigned short)(src[0]))<<4)) | (src[3] >> 4)); … … 174 179 *(src+8) = (unsigned char) ((pixVal0)); //7 (=>0) } 175 180 } 176 for (j=CAM_ RAW_ROWPIX;j; j-=8, src+=10){181 for (j=CAM_CHDK_RAW_ROWPIX;j; j-=8, src+=10){ 177 182 pixVal0=((0x3fc&(((unsigned short)(src[1]))<<2)) | (src[0] >> 6)); 178 183 pixVal1=((0x3f0&(((unsigned short)(src[0]))<<4)) | (src[3] >> 4)); … … 237 242 238 243 // Loop through picture rows 239 for (i=CAM_ RAW_ROWS; i;i-=2){244 for (i=CAM_CHDK_RAW_ROWS; i;i-=2){ 240 245 // Loop through picture columns 241 for (j=CAM_ RAW_ROWPIX; j; j-=8, src+=10){246 for (j=CAM_CHDK_RAW_ROWPIX; j; j-=8, src+=10){ 242 247 pixVal0=((0x3fc&(((unsigned short)(src[1]))<<2)) | (src[0] >> 6)); 243 248 pixVal1=((0x3f0&(((unsigned short)(src[0]))<<4)) | (src[3] >> 4)); … … 302 307 *(src+8) = (unsigned char) ((pixVal0)); //7 (=>0) 303 308 } 304 for (j=CAM_ RAW_ROWPIX;j; j-=8, src+=10){309 for (j=CAM_CHDK_RAW_ROWPIX;j; j-=8, src+=10){ 305 310 pixVal0=((0x3fc&(((unsigned short)(src[1]))<<2)) | (src[0] >> 6)); 306 311 pixVal1=((0x3f0&(((unsigned short)(src[0]))<<4)) | (src[3] >> 4)); … … 371 376 short EVbias = shooting_get_ev_correction1(); 372 377 373 switch( conf.curve_enable) {378 switch(*conf_curve_enable) { 374 379 case 0: 375 380 break; … … 385 390 case 2: 386 391 case 3: // +1EV, +2EV 387 if (current_curve_type == CURVE_SYSTEM) curveL_apply( conf.curve_enable & 1 );392 if (current_curve_type == CURVE_SYSTEM) curveL_apply( *conf_curve_enable & 1 ); 388 393 break; 389 394 case 4: // Auto DR … … 401 406 } 402 407 408 // ========= MODULE INIT ================= 409 410 #include "module_load.h" 411 412 413 int module_idx=-1; 414 415 /***************** BEGIN OF AUXILARY PART ********************* 416 ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 417 **************************************************************/ 418 419 void* MODULE_EXPORT_LIST[] = { 420 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 421 /* 1 */ (void*)5, 422 423 curve_set_mode, 424 curve_init_mode, 425 curve_apply, 426 }; 427 428 429 //--------------------------------------------------------- 430 // PURPOSE: Bind module symbols with chdk. 431 // Required function 432 // PARAMETERS: pointer to chdk list of export 433 // RETURN VALUE: 1 error, 0 ok 434 //--------------------------------------------------------- 435 int _module_loader( void** chdk_export_list ) 436 { 437 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 438 return 1; 439 440 // Safe bind of conf. 441 tConfigVal configVal; 442 CONF_BIND_STR(185, conf_curve_file); 443 CONF_BIND_INT(186, conf_curve_enable ); 444 445 // Startup initialize 446 curve_init_mode(); 447 448 return 0; 449 } 450 451 452 453 //--------------------------------------------------------- 454 // PURPOSE: Finalize module operations (close allocs, etc) 455 // RETURN VALUE: 0-ok, 1-fail 456 //--------------------------------------------------------- 457 int _module_unloader() 458 { 459 // This could be happens only if on-load mistake 460 // CHDK never unload this library (but load only if needed) 461 // Reason: a) curve_set_mode by LUA is not stored anywhere 462 // b) perfomance reason - to avoid load on each raw_processing 463 return 0; 464 } 465 466 467 /******************** Module Information structure ******************/ 468 469 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 470 sizeof(struct ModuleInfo), 471 472 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 473 ANY_PLATFORM_ALLOWED, // Specify platform dependency 474 MODULEINFO_FLAG_SYSTEM, // flag 475 (int32_t)"Curves (dll)", // Module name 476 1, 0, // Module version 477 (int32_t)"Apply curves to shots. Only 10bit sensor version" 478 }; 479 480 481 /*************** END OF AUXILARY PART *******************/ 482 483 403 484 #endif -
trunk/core/curves.h
r709 r1505 5 5 6 6 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 7 20 //------------------------------------------------------------------- 8 extern void curve_set_mode();9 extern void curve_init_mode();10 extern void curve_apply();11 21 //------------------------------------------------------------------- 12 22 -
trunk/core/edgeoverlay.c
r1499 r1505 1 1 #include "platform.h" 2 2 3 #ifdef OPT_EDGEOVERLAY4 3 #include "edgeoverlay.h" 5 4 #include "conf.h" … … 8 7 #include "gui_draw.h" 9 8 #include "bitvector.h" 9 #include "module_exportlist.h" 10 10 11 11 12 // the way we save edge overlays on their own... … … 13 14 #define EDGE_FILE_FORMAT EDGE_FILE_PREFIX "%04d.edg" 14 15 #define EDGE_SLICES 2 16 17 int* conf_edge_overlay_filter; 18 color* conf_osd_color; 19 int* conf_edge_overlay_zoom; 20 int* conf_edge_overlay_thresh; 21 color* conf_edge_overlay_color; 22 int* conf_edge_overlay_pano; 23 int* conf_edge_overlay_pano_overlap; 24 int* conf_edge_overlay_show; 25 int* conf_edge_overlay_play; 15 26 16 27 typedef enum _edge_fsm_state … … 56 67 memset(edgebuf->ptr, 0, edgebuf->ptrLen); 57 68 } 58 if ( conf.edge_overlay_filter && (smbuf == NULL))69 if (*conf_edge_overlay_filter && (smbuf == NULL)) 59 70 { 60 71 smbuf = (unsigned char*)malloc(viewport_byte_width*3); … … 64 75 { 65 76 // Disable filtering if we do not have enough memory for it 66 conf.edge_overlay_filter = 0;77 *conf_edge_overlay_filter = 0; 67 78 } 68 79 } … … 125 136 char msg[64]; 126 137 FILE *fd; 127 DIR* d;138 STD_DIR* d; 128 139 int fnum = 0; 129 140 int fr = 0; 130 141 int zoom = 0; 131 struct dirent* de;142 struct STD_dirent* de; 132 143 static struct utimbuf t; 133 144 // nothing to save? then dont save … … 135 146 if( !is_buffer_ready() ) 136 147 { 137 draw_string(0, 0, "No overlay to save.", conf.osd_color);148 draw_string(0, 0, "No overlay to save.", *conf_osd_color); 138 149 return; 139 150 } … … 142 153 143 154 // first figure out the most appropriate filename to use 144 d = opendir(EDGE_SAVE_DIR);155 d = safe_opendir(EDGE_SAVE_DIR); 145 156 if( ! d ) 146 157 { … … 148 159 } 149 160 150 while( (de = readdir(d)) )161 while( (de = safe_readdir(d)) ) 151 162 { 152 163 fr = get_edge_file_num(de->d_name); … … 170 181 utime(fn, &t); 171 182 sprintf(msg, "Saved as %s",fn); 172 draw_string(0, 0, msg, conf.osd_color);173 } 174 closedir(d);183 draw_string(0, 0, msg, *conf_osd_color); 184 } 185 safe_closedir(d); 175 186 } 176 187 … … 192 203 { 193 204 fsm_state = EDGE_FROZEN; // switch to "edge overlay frozen"-mode 194 if ( conf.edge_overlay_zoom)205 if (*conf_edge_overlay_zoom) 195 206 { 196 207 shooting_set_zoom(zoom); … … 300 311 memset(edgebuf->ptr + slice*compressed_slice, 0, compressed_slice); 301 312 302 if ( conf.edge_overlay_filter)313 if (*conf_edge_overlay_filter) 303 314 { 304 315 // Prefill smbuf with three lines of avergae-filtered data. … … 322 333 shutter_fullpress |= kbd_is_key_pressed(KEY_SHOOT_FULL); 323 334 324 if ( conf.edge_overlay_filter)335 if (*conf_edge_overlay_filter) 325 336 { 326 337 // We need to shift up our smbuf one line, … … 374 385 conv2 = -conv2; 375 386 376 if (conv1 + conv2 > conf.edge_overlay_thresh)387 if (conv1 + conv2 > *conf_edge_overlay_thresh) 377 388 { 378 389 bv_set(edgebuf, (y-viewport_yoffset-EDGE_HMARGIN)*viewport_width + xdiv3, 1); … … 404 415 conv2 = -conv2; 405 416 406 if (conv1 + conv2 > conf.edge_overlay_thresh)417 if (conv1 + conv2 > *conf_edge_overlay_thresh) 407 418 { 408 419 bv_set(edgebuf, (y-viewport_yoffset-EDGE_HMARGIN)*viewport_width + xdiv3+1, 1); … … 418 429 // care so much about performance, you can enable it. 419 430 // 420 // if ( conf.edge_overlay_filter)431 // if (*conf_edge_overlay_filter) 421 432 // { 422 433 // // Here we do basic filtering on the detected edges. … … 453 464 // bv_get(edgebuf, (y+1)*viewport_width + (x+1)); 454 465 // 455 // if (! conf.edge_overlay_show)466 // if (!*conf_edge_overlay_show) 456 467 // { 457 468 // if (sum >= 5) // if we have at least 5 neighboring edges … … 481 492 int x_off, y_off; 482 493 483 const color cl = conf.edge_overlay_color;494 const color cl = *conf_edge_overlay_color; 484 495 const int y_slice_min = viewport_yoffset+EDGE_HMARGIN+ slice *slice_height; 485 496 const int y_slice_max = viewport_yoffset+EDGE_HMARGIN+(slice+1)*slice_height; … … 512 523 const int aspect_correct_x_off = x_off; 513 524 const int bEdge = bv_get(edgebuf, y_edgebuf + x); 514 const int bDraw = bEdge || (draw_get_pixel(aspect_correct_x_off, y_off) == conf.edge_overlay_color);515 const color cl = bEdge ? conf.edge_overlay_color : 0;525 const int bDraw = bEdge || (draw_get_pixel(aspect_correct_x_off, y_off) == *conf_edge_overlay_color); 526 const color cl = bEdge ? *conf_edge_overlay_color : 0; 516 527 if (bEdge || bDraw) 517 528 draw_pixel(aspect_correct_x_off, y_off, cl); … … 571 582 const int x_max = (viewport_width - 2); 572 583 573 switch( conf.edge_overlay_pano)584 switch(*conf_edge_overlay_pano) 574 585 { 575 586 case 0: // pano off … … 578 589 break; 579 590 case 1: // pano from left to right 580 xoffset = -x_max*(100- conf.edge_overlay_pano_overlap)/100;591 xoffset = -x_max*(100-*conf_edge_overlay_pano_overlap)/100; 581 592 break; 582 593 case 2: // pano from top to bottom 583 yoffset = -y_max*(100- conf.edge_overlay_pano_overlap)/100;594 yoffset = -y_max*(100-*conf_edge_overlay_pano_overlap)/100; 584 595 break; 585 596 case 3: // pano from right to left 586 xoffset = x_max*(100- conf.edge_overlay_pano_overlap)/100;597 xoffset = x_max*(100-*conf_edge_overlay_pano_overlap)/100; 587 598 break; 588 599 case 4: // pano from bottom to top 589 yoffset = y_max*(100- conf.edge_overlay_pano_overlap)/100;600 yoffset = y_max*(100-*conf_edge_overlay_pano_overlap)/100; 590 601 break; 591 602 case 5: // free mode … … 596 607 } 597 608 } 609 598 610 599 611 … … 607 619 void edge_overlay() 608 620 { 609 610 621 // Was the shutter fully pressed the last time we ran? 611 622 // We use this to make sure that the user has released … … 625 636 const int bHalfPress = kbd_is_key_pressed(KEY_SHOOT_HALF); 626 637 const int bPlayMode = (mode_get() & MODE_MASK) == MODE_PLAY; 627 const int bPanoramaMode = ( conf.edge_overlay_pano != 0);628 const int bNeedHalfPress = ( conf.edge_overlay_show != 1);629 const int bDisplayInPlay = ( conf.edge_overlay_play == 1);638 const int bPanoramaMode = (*conf_edge_overlay_pano != 0); 639 const int bNeedHalfPress = (*conf_edge_overlay_show != 1); 640 const int bDisplayInPlay = (*conf_edge_overlay_play == 1); 630 641 const int bGuiModeNone = (gui_get_mode() == GUI_MODE_NONE); 631 642 const int bGuiModeAlt = (gui_get_mode() == GUI_MODE_ALT); … … 710 721 // calculations. 711 722 bFullPress |= draw_edge_overlay(); 712 draw_string(0, 0, "Frozen", conf.osd_color);723 draw_string(0, 0, "Frozen", *conf_osd_color); 713 724 } 714 725 … … 743 754 } // function 744 755 745 #endif 746 756 757 758 759 760 // ========= MODULE INIT ================= 761 762 #include "module_load.h" 763 int module_idx=-1; 764 765 /***************** BEGIN OF AUXILARY PART ********************* 766 ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 767 **************************************************************/ 768 769 void* MODULE_EXPORT_LIST[] = { 770 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 771 /* 1 */ (void*)5, 772 773 edge_overlay, 774 save_edge_overlay, 775 load_edge_overlay 776 }; 777 778 779 //--------------------------------------------------------- 780 // PURPOSE: Bind module symbols with chdk. 781 // Required function 782 // PARAMETERS: pointer to chdk list of export 783 // RETURN VALUE: 1 error, 0 ok 784 //--------------------------------------------------------- 785 int _module_loader( void** chdk_export_list ) 786 { 787 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 788 return 1; 789 790 tConfigVal configVal; 791 CONF_BIND_INT(188, conf_edge_overlay_thresh); 792 CONF_BIND_COLOR(189, conf_edge_overlay_color); 793 CONF_BIND_INT(222, conf_edge_overlay_play); 794 CONF_BIND_INT(223, conf_edge_overlay_pano); 795 CONF_BIND_INT(224, conf_edge_overlay_zoom); 796 CONF_BIND_INT(241, conf_edge_overlay_filter); 797 CONF_BIND_INT(242, conf_edge_overlay_show); 798 CONF_BIND_INT(243, conf_edge_overlay_pano_overlap); 799 CONF_BIND_COLOR( 28, conf_osd_color); 800 801 return 0; 802 } 803 804 805 806 //--------------------------------------------------------- 807 // PURPOSE: Finalize module operations (close allocs, etc) 808 // RETURN VALUE: 0-ok, 1-fail 809 //--------------------------------------------------------- 810 int _module_unloader() 811 { 812 // This could be happens only if on-load mistake 813 // CHDK never unload this library (but load only if needed) 814 // Reason: edve_overlay allocate different bufs which should be kept 815 // because even if we turn off edgeovr we could turn on back and 816 // should get same content. 817 return 0; 818 } 819 820 /******************** Module Information structure ******************/ 821 822 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 823 sizeof(struct ModuleInfo), 824 825 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 826 ANY_PLATFORM_ALLOWED, // Specify platform dependency 827 MODULEINFO_FLAG_SYSTEM, // flag 828 (int32_t)"Edge Overalay (dll)",// Module name 829 1, 0, // Module version 830 (int32_t)"Implementation one of core modes" 831 }; 832 833 834 /*************** END OF AUXILARY PART *******************/ 835 -
trunk/core/edgeoverlay.h
r928 r1505 9 9 #define EDGE_SAVE_DIR "A/CHDK/EDGE" 10 10 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 11 19 void edge_overlay(); 12 20 void save_edge_overlay(void); 13 21 void load_edge_overlay( const char* ); 22 #endif 14 23 15 24 #endif -
trunk/core/gui.c
r1497 r1505 14 14 #include "gui_mbox.h" 15 15 #include "gui_mpopup.h" 16 #ifdef OPT_GAME_REVERSI17 #include "gui_reversi.h"18 #endif19 #ifdef OPT_GAME_SOKOBAN20 #include "gui_sokoban.h"21 #endif22 #ifdef OPT_GAME_CONNECT423 #include "gui_4wins.h"24 #endif25 #ifdef OPT_GAME_MASTERMIND26 #include "gui_mastermind.h"27 #endif28 16 #include "console.h" 29 17 #ifdef OPT_DEBUGGING 30 18 #include "gui_debug.h" 31 #include "gui_bench.h"32 19 #endif 33 20 #include "gui_fselect.h" … … 39 26 #include "gui_read.h" 40 27 #endif 41 #ifdef OPT_CALENDAR42 #include "gui_calendar.h"43 #endif44 28 #include "gui_grid.h" 45 29 #include "histogram.h" … … 51 35 #endif 52 36 #ifdef OPT_EDGEOVERLAY 53 #include " edgeoverlay.h"37 #include "modules.h" 54 38 #endif 55 39 #ifdef OPT_SCRIPTING … … 57 41 int script_params_has_changed=0; 58 42 #endif 43 #include "module_load.h" 44 59 45 //------------------------------------------------------------------- 60 46 … … 160 146 static void gui_show_build_info(int arg); 161 147 static void gui_show_memory_info(int arg); 162 static void gui_draw_palette(int arg); 163 static void gui_draw_reversi(int arg); 164 static void gui_draw_sokoban(int arg); 165 static void gui_draw_4wins(int arg); 166 static void gui_draw_mastermind(int arg); 148 static void gui_modules_menu_load(); 149 167 150 #ifdef OPT_DEBUGGING 168 static void gui_draw_debug(int arg);169 static void gui_draw_bench(int arg);170 151 void gui_compare_props(int arg); 171 152 static void gui_menuproc_break_card(int arg); … … 318 299 #endif 319 300 320 static CMenuItem games_submenu_items[] = {321 #ifdef OPT_GAME_REVERSI322 MENU_ITEM(0x38,LANG_MENU_GAMES_REVERSI, MENUITEM_PROC, gui_draw_reversi, 0 ),323 #endif324 #ifdef OPT_GAME_SOKOBAN325 MENU_ITEM(0x38,LANG_MENU_GAMES_SOKOBAN, MENUITEM_PROC, gui_draw_sokoban, 0 ),326 #endif327 #ifdef OPT_GAME_CONNECT4328 MENU_ITEM(0x38,LANG_MENU_GAMES_CONNECT4, MENUITEM_PROC, gui_draw_4wins, 0 ),329 #endif330 #ifdef OPT_GAME_MASTERMIND331 MENU_ITEM(0x38,LANG_MENU_GAMES_MASTERMIND, MENUITEM_PROC, gui_draw_mastermind, 0 ),332 #endif333 MENU_ITEM(0x51,LANG_MENU_BACK, MENUITEM_UP, 0, 0 ),334 {0}335 };336 static CMenu games_submenu = {0x38,LANG_MENU_GAMES_TITLE, NULL, games_submenu_items };337 338 301 static const char* gui_autoiso_shutter_modes[] = { "Auto", "1/8s", "1/15s", "1/30s", "1/60s", "1/125s", "1/250s", "1/500s", "1/1000s"}; 339 302 static CMenuItem autoiso_submenu_items[] = { … … 377 340 MENU_ITEM(0x2a,LANG_MENU_DEBUG_TASKLIST_START, MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &debug_tasklist_start, MENU_MINMAX(0, 63) ), 378 341 MENU_ITEM(0x5c,LANG_MENU_DEBUG_SHOW_MISC_VALS, MENUITEM_BOOL, &conf.debug_misc_vals_show, 0 ), 379 MENU_ITEM(0x2a,LANG_MENU_DEBUG_MEMORY_BROWSER, MENUITEM_PROC, gui_draw_debug, 0 ),380 MENU_ITEM(0x2a,LANG_MENU_DEBUG_BENCHMARK, MENUITEM_PROC, gui_draw_bench, 0 ),381 342 MENU_ENUM2(0x5c,LANG_MENU_DEBUG_SHORTCUT_ACTION, &conf.debug_shortcut_action, gui_debug_shortcut_modes ), 382 343 MENU_ITEM(0x5c,LANG_MENU_RAW_TIMER, MENUITEM_BOOL, &conf.raw_timer, 0 ), … … 397 358 static CMenuItem misc_submenu_items[] = { 398 359 MENU_ITEM(0x35,LANG_MENU_MISC_FILE_BROWSER, MENUITEM_PROC, gui_draw_fselect, 0 ), 399 #ifdef OPT_CALENDAR 400 MENU_ITEM(0x36,LANG_MENU_MISC_CALENDAR, MENUITEM_PROC, gui_draw_calendar, 0 ), 401 #endif 360 MENU_ITEM(0x65,(int)"Modules", MENUITEM_TEXT, 0, 0 ), 402 361 #ifdef OPT_TEXTREADER 403 362 MENU_ITEM(0x37,LANG_MENU_MISC_TEXT_READER, MENUITEM_SUBMENU, &reader_submenu, 0 ), 404 #endif405 #if defined (OPT_GAME_REVERSI) || (OPT_GAME_SOKOBAN || (OPT_GAME_CONNECT4) || OPT_GAME_MASTERMIND)406 MENU_ITEM(0x38,LANG_MENU_MISC_GAMES, MENUITEM_SUBMENU, &games_submenu, 0 ),407 363 #endif 408 364 #if CAM_SWIVEL_SCREEN … … 418 374 #endif 419 375 MENU_ITEM(0x5d,LANG_MENU_MISC_DISABLE_LCD_OFF, MENUITEM_ENUM, gui_alt_power_enum, 0 ), 420 MENU_ITEM(0x65,LANG_MENU_MISC_PALETTE, MENUITEM_PROC, gui_draw_palette, 0 ),421 376 MENU_ITEM(0x80,LANG_MENU_MISC_BUILD_INFO, MENUITEM_PROC, gui_show_build_info, 0 ), 422 377 MENU_ITEM(0x80,LANG_MENU_MISC_MEMORY_INFO, MENUITEM_PROC, gui_show_memory_info, 0 ), … … 1085 1040 gui_enum_value_change(&conf.curve_enable,change,sizeof(modes)/sizeof(modes[0])); 1086 1041 1087 if(change )1042 if(change && curve_init_mode) 1088 1043 curve_init_mode(); 1089 1044 return modes[conf.curve_enable]; … … 1138 1093 1139 1094 void gui_load_script(int arg) { 1140 gui_fselect_init(LANG_STR_SELECT_SCRIPT_FILE, conf.script_file, "A/CHDK/SCRIPTS", gui_load_script_selected);1095 module_fselect_init(LANG_STR_SELECT_SCRIPT_FILE, conf.script_file, "A/CHDK/SCRIPTS", gui_load_script_selected); 1141 1096 } 1142 1097 … … 1517 1472 void gui_raw_develop(int arg){ 1518 1473 int m=mode_get(); 1519 gui_fselect_init(LANG_RAW_DEVELOP_SELECT_FILE, "A/DCIM", "A", raw_fselect_cb);1474 module_fselect_init(LANG_RAW_DEVELOP_SELECT_FILE, "A/DCIM", "A", raw_fselect_cb); 1520 1475 } 1521 1476 … … 1630 1585 1631 1586 //------------------------------------------------------------------- 1632 static volatile enum Gui_Mode gui_mode; 1587 static volatile gui_mode_t gui_mode; // current gui mode. if <GUI_MODE_LASTIDX - idx in guiHandlers (core modes), otherwise pointer to gui_handler object (module modes) 1588 1633 1589 static volatile int gui_restore; 1634 1590 static volatile int gui_in_redraw; … … 1638 1594 static Conf old_conf; 1639 1595 #endif 1596 1597 extern gui_handler guiHandlers[]; 1640 1598 1641 1599 //------------------------------------------------------------------- … … 1650 1608 } 1651 1609 gui_splash = (conf.splash_show)?SPLASH_TIME:0; 1610 1611 gui_modules_menu_load(); 1652 1612 user_menu_restore(); 1653 1613 gui_lang_init(); … … 1660 1620 #ifdef OPT_CURVES 1661 1621 // initialize curves, loading files if required by current mode 1662 curve_init_mode();1622 //curve_init_mode(); // @tsv it will be initialize on first load 1663 1623 #endif 1664 1624 #if ZOOM_OVERRIDE … … 1666 1626 // if (conf.zoom_override) shooting_set_zoom(conf.zoom_override_value); 1667 1627 #endif 1628 } 1629 1630 1631 //------------------------------------------------------------------- 1632 void gui_modules_menu_load(int arg){ 1633 1634 misc_submenu_items[1].type=MENUITEM_TEXT; 1635 1636 unsigned int argv[] ={ (unsigned int)MODULES_PATH, 1637 (unsigned int)(&misc_submenu_items[1]) 1638 }; 1639 module_run("modmenu.flt", 0, 2,argv, UNLOAD_IF_ERR ); 1668 1640 } 1669 1641 … … 1674 1646 // TODO we could sanity check here, but curve_set_type should fail gracefullish 1675 1647 strcpy(conf.curve_file,fn); 1676 if(conf.curve_enable == 1 )1648 if(conf.curve_enable == 1 && curve_init_mode) 1677 1649 curve_init_mode(); 1678 1650 } … … 1681 1653 //------------------------------------------------------------------- 1682 1654 void gui_load_curve(int arg) { 1683 gui_fselect_init(LANG_STR_SELECT_CURVE_FILE, conf.curve_file, CURVE_DIR, gui_load_curve_selected); 1684 } 1685 1686 #endif 1687 //------------------------------------------------------------------- 1688 enum Gui_Mode gui_get_mode() { 1655 module_fselect_init(LANG_STR_SELECT_CURVE_FILE, conf.curve_file, CURVE_DIR, gui_load_curve_selected); 1656 } 1657 1658 #endif 1659 1660 1661 // Small hack: use understandable name to reused data member 1662 #define binded_gui_mode_ptr kbd_process 1663 1664 //------------------------------------------------------------------- 1665 gui_mode_t gui_get_mode() { 1666 if ( gui_mode >= GUI_MODE_COUNT ) 1667 { 1668 int mode; 1669 for (mode=0;mode<GUI_MODE_COUNT;mode++) 1670 { 1671 if ( (guiHandlers[mode].flags & GUI_MODE_FLAG_ALIAS) && 1672 guiHandlers[mode].binded_gui_mode_ptr == (void*)gui_mode ) 1673 return mode; 1674 } 1675 } 1689 1676 return gui_mode; 1690 1677 } 1691 1678 1692 1679 //------------------------------------------------------------------- 1693 void gui_set_mode(enum Gui_Mode mode) { 1680 void gui_set_mode(gui_mode_t mode) 1681 { 1682 if ( gui_mode == mode ) 1683 return; 1684 1685 if ( mode < GUI_MODE_COUNT && 1686 (guiHandlers[mode].flags & GUI_MODE_FLAG_ALIAS) ) 1687 { 1688 mode = (unsigned int)guiHandlers[mode].binded_gui_mode_ptr; 1689 } 1690 1691 // Sanity check for case module pointer - is this really gui_handler 1692 if ( mode >= GUI_MODE_COUNT && ((gui_handler*)mode)->magicnum != GUI_MODE_MAGICNUM ) { 1693 // If sanity failed (module is unload) - set to default mode 1694 gui_mode = GUI_MODE_NONE; 1695 draw_restore(); 1696 return; 1697 } 1698 1694 1699 #ifdef CAM_TOUCHSCREEN_UI 1695 1700 if (((gui_mode == 0) != (mode == 0)) || // Change from GUI_MODE_NONE to any other or vice-versa … … 1699 1704 gui_mode = mode; 1700 1705 } 1706 1707 //------------------------------------------------------------------- 1708 // PURPOSE: bind module struct to 1709 // RETUN: 0 - fail, 1 - ok 1710 int gui_bind_mode(int core_mode, gui_handler* handler) { 1711 1712 // sanity checks 1713 if ( core_mode >= GUI_MODE_COUNT || 1714 (guiHandlers[core_mode].flags & GUI_MODE_FLAG_ALIAS)==0 1715 ) 1716 return 0; 1717 1718 if ( handler && handler->magicnum != GUI_MODE_MAGICNUM ) 1719 return 0; 1720 1721 // check is this module is already binded (loaded with different name) 1722 gui_handler* bind_gui_handler = (gui_handler*)guiHandlers[core_mode].binded_gui_mode_ptr; 1723 if ( bind_gui_handler && bind_gui_handler->magicnum == GUI_MODE_MAGICNUM ) 1724 return 0; 1725 1726 guiHandlers[core_mode].binded_gui_mode_ptr = (void*)handler; 1727 return 1; 1728 } 1729 1730 #undef binded_gui_mode_ptr 1731 1701 1732 1702 1733 //------------------------------------------------------------------- … … 1961 1992 } 1962 1993 1963 // Menu button handled for text reader1964 #ifdef OPT_TEXTREADER1965 void gui_read_kbd_process_menu_btn()1966 {1967 gui_read_kbd_process();1968 gui_default_kbd_process_menu_btn();1969 }1970 #endif1971 1972 1994 // Menu button handled for Menu mode 1973 1995 void gui_menu_kbd_process_menu_btn() … … 1988 2010 1989 2011 //------------------------------------------------------------------- 1990 // Structure to store gui redraw and kbd process handlers for each mode1991 typedef struct 2012 // GUI handler table (entries must be in the same order and have the same number of entries as Gui_Mode enum) 2013 gui_handler guiHandlers[GUI_MODE_COUNT] = 1992 2014 { 1993 void (*redraw)(void); // Called to redraw screen 1994 void (*kbd_process)(void); // Main button handler for mode 1995 void (*kbd_process_menu_btn)(void); // Menu button handler for mode 1996 } gui_handler; 1997 1998 // GUI handler table (entries must be in the same order and have the same number of entries as Gui_Mode enum) 1999 gui_handler guiHandlers[] = 2000 { 2001 /*GUI_MODE_NONE*/ { gui_draw_osd, 0, 0 }, 2002 /*GUI_MODE_ALT*/ { gui_chdk_draw, gui_chdk_kbd_process, gui_chdk_kbd_process_menu_btn }, 2003 /*GUI_MODE_MENU*/ { gui_menu_draw, gui_menu_kbd_process, gui_menu_kbd_process_menu_btn }, 2004 /*GUI_MODE_PALETTE*/ { gui_palette_draw, gui_palette_kbd_process, gui_default_kbd_process_menu_btn }, 2005 /*GUI_MODE_MBOX*/ { gui_mbox_draw, gui_mbox_kbd_process, 0 }, 2006 #ifdef OPT_GAME_REVERSI 2007 /*GUI_MODE_REVERSI*/ { gui_reversi_draw, gui_reversi_kbd_process, gui_default_kbd_process_menu_btn }, 2008 #else 2009 { 0, 0, 0 }, 2010 #endif 2011 #ifdef OPT_GAME_SOKOBAN 2012 /*GUI_MODE_SOKOBAN*/ { gui_sokoban_draw, gui_sokoban_kbd_process, gui_default_kbd_process_menu_btn }, 2013 #else 2014 { 0, 0, 0 }, 2015 #endif 2016 #ifdef OPT_DEBUGGING 2017 /*GUI_MODE_DEBUG*/ { gui_debug_draw, gui_debug_kbd_process, gui_default_kbd_process_menu_btn }, 2018 #else 2019 { 0, 0, 0 }, 2020 #endif 2021 /*GUI_MODE_FSELECT*/ { gui_fselect_draw, gui_fselect_kbd_process, gui_fselect_kbd_process }, 2022 #ifdef OPT_TEXTREADER 2023 /*GUI_MODE_READ*/ { gui_read_draw, gui_read_kbd_process, gui_read_kbd_process_menu_btn }, 2024 #else 2025 { 0, 0, 0 }, 2026 #endif 2027 /*GUI_MODE_OSD*/ { gui_osd_draw, gui_osd_kbd_process, gui_default_kbd_process_menu_btn }, 2028 #ifdef OPT_CALENDAR 2029 /*GUI_MODE_CALENDAR*/ { gui_calendar_draw, gui_calendar_kbd_process, gui_default_kbd_process_menu_btn }, 2030 #else 2031 { 0, 0, 0 }, 2032 #endif 2033 #ifdef OPT_DEBUGGING 2034 /*GUI_MODE_BENCH*/ { gui_bench_draw, gui_bench_kbd_process, gui_default_kbd_process_menu_btn }, 2035 #else 2036 { 0, 0, 0 }, 2037 #endif 2038 /*GUI_MODE_MPOPUP*/ { gui_mpopup_draw, gui_mpopup_kbd_process, gui_mpopup_kbd_process }, 2039 #ifdef OPT_GAME_CONNECT4 2040 /*GUI_MODE_4WINS*/ { gui_4wins_draw, gui_4wins_kbd_process, gui_default_kbd_process_menu_btn }, 2041 #else 2042 { 0, 0, 0 }, 2043 #endif 2044 #ifdef OPT_GAME_MASTERMIND 2045 /*GUI_MODE_MASTERMIND*/ { gui_mastermind_draw, gui_mastermind_kbd_process, gui_default_kbd_process_menu_btn }, 2046 #else 2047 { 0, 0, 0 }, 2048 #endif 2015 /*GUI_MODE_NONE*/ { gui_draw_osd, 0, 0, 0, GUI_MODE_MAGICNUM }, 2016 /*GUI_MODE_ALT*/ { gui_chdk_draw, gui_chdk_kbd_process, gui_chdk_kbd_process_menu_btn, 0, GUI_MODE_MAGICNUM }, 2017 /*GUI_MODE_MENU*/ { gui_menu_draw, gui_menu_kbd_process, gui_menu_kbd_process_menu_btn, 0, GUI_MODE_MAGICNUM }, 2018 /*GUI_MODE_ALIAS_PALETTE*/ { 0, 0, 0, GUI_MODE_FLAG_ALIAS, GUI_MODE_MAGICNUM }, 2019 /*GUI_MODE_MBOX*/ { gui_mbox_draw, gui_mbox_kbd_process, 0, GUI_MODE_FLAG_NORESTORE_ON_SWITCH, GUI_MODE_MAGICNUM }, 2020 /*GUI_MODE_ALIAS_FSELECT*/ { 0, 0, 0, GUI_MODE_FLAG_ALIAS, GUI_MODE_MAGICNUM }, 2021 /*GUI_MODE_OSD*/ { gui_osd_draw, gui_osd_kbd_process, gui_default_kbd_process_menu_btn, 0, GUI_MODE_MAGICNUM }, // THIS IS OSD LAYOUT EDITOR 2022 /*GUI_MODE_ALIAS_MPOPUP*/ { 0, 0, 0, GUI_MODE_FLAG_ALIAS, GUI_MODE_MAGICNUM }, 2049 2023 }; 2024 2050 2025 2051 2026 //------------------------------------------------------------------- … … 2053 2028 void gui_redraw() 2054 2029 { 2055 enum Gui_Mode gui_mode_old; 2030 static gui_mode_t gui_mode_prev_tick = GUI_MODE_NONE; 2031 gui_mode_t gui_mode_old; 2032 2033 static int flag_gui_enforce_redraw = 0; 2056 2034 2057 2035 #ifdef CAM_DETECT_SCREEN_ERASE … … 2059 2037 { 2060 2038 draw_set_guard(); 2061 gui_menu_force_redraw(); 2062 gui_fselect_force_redraw(); 2039 2040 flag_gui_enforce_redraw |= GUI_REDRAWFLAG_ERASEGUARD; 2041 //gui_menu_force_redraw(); 2042 //gui_fselect_force_redraw(); //@tsv 2063 2043 #ifdef CAM_TOUCHSCREEN_UI 2064 2044 extern int redraw_buttons; … … 2079 2059 2080 2060 // Call redraw handler 2081 if (guiHandlers[gui_mode].redraw) guiHandlers[gui_mode].redraw(); 2061 gui_handler* cur_gui_handler = (gui_mode<GUI_MODE_COUNT)? (&guiHandlers[gui_mode]) : (gui_handler*)gui_mode; 2062 if (cur_gui_handler->redraw) cur_gui_handler->redraw(flag_gui_enforce_redraw); 2063 flag_gui_enforce_redraw=0; 2082 2064 2083 2065 // Forced redraw if needed 2084 2066 gui_in_redraw = 0; 2085 if ((gui_mode_old != gui_mode && (gui_mode_old != GUI_MODE_NONE && gui_mode_old != GUI_MODE_ALT) && (gui_mode != GUI_MODE_MBOX && gui_mode != GUI_MODE_MPOPUP)) || gui_restore) { 2086 if (gui_restore) gui_menu_force_redraw(); 2067 cur_gui_handler = (gui_mode<GUI_MODE_COUNT)? (&guiHandlers[gui_mode]) : (gui_handler*)gui_mode; 2068 if ((gui_mode_old != gui_mode 2069 && (gui_mode_old != GUI_MODE_NONE && gui_mode_old != GUI_MODE_ALT) 2070 && !(cur_gui_handler->flags & GUI_MODE_FLAG_NORESTORE_ON_SWITCH)) 2071 || gui_restore ) 2072 { 2073 2074 if (gui_restore) 2075 flag_gui_enforce_redraw |= GUI_REDRAWFLAG_DRAW_RESTORED; 2087 2076 gui_restore = 0; 2088 if (gui_mode != GUI_MODE_REVERSI && gui_mode != GUI_MODE_SOKOBAN && gui_mode != GUI_MODE_4WINS && gui_mode != GUI_MODE_MASTERMIND) 2077 2078 if ( !( cur_gui_handler->flags & GUI_MODE_FLAG_NODRAWRESTORE) ) 2089 2079 draw_restore(); 2090 2080 } 2081 2082 if ( gui_mode_prev_tick != gui_mode ) { 2083 flag_gui_enforce_redraw |= GUI_REDRAWFLAG_MODE_WAS_CHANGED; 2084 gui_mode_prev_tick = gui_mode; 2085 } 2091 2086 } 2092 2087 … … 2095 2090 void gui_kbd_process() 2096 2091 { 2092 gui_handler* cur_gui_handler = (gui_mode<GUI_MODE_COUNT)? (&guiHandlers[gui_mode]) : (gui_handler*)gui_mode; 2093 2097 2094 // Call menu button handler if menu button pressed 2098 2095 if (kbd_is_key_clicked(KEY_MENU)) 2099 2096 { 2100 if ( guiHandlers[gui_mode].kbd_process_menu_btn) guiHandlers[gui_mode].kbd_process_menu_btn();2097 if (cur_gui_handler->kbd_process_menu_btn) cur_gui_handler->kbd_process_menu_btn(); 2101 2098 return; 2102 2099 } 2103 2100 2104 2101 // Call mode handler for other buttons 2105 if ( guiHandlers[gui_mode].kbd_process) guiHandlers[gui_mode].kbd_process();2102 if (cur_gui_handler->kbd_process) cur_gui_handler->kbd_process(); 2106 2103 } 2107 2104 … … 2143 2140 #endif 2144 2141 draw_restore(); 2145 if (gui_mode == GUI_MODE_READ && !rbf_load(conf.menu_rbf_file))2146 rbf_load_from_8x16(current_font);2147 2142 rbf_set_codepage(FONT_CP_WIN); 2148 2143 vid_turn_on_updates(); 2149 2144 gui_set_mode(GUI_MODE_NONE); 2145 2146 // Unload all modules which are marked as safe to unload 2147 module_async_unload_allrunned(0); 2150 2148 2151 2149 conf_update_prevent_shutdown(); … … 2607 2605 2608 2606 //------------------------------------------------------------------- 2609 void gui_draw_palette(int arg) {2610 draw_restore();2611 gui_palette_init(PALETTE_MODE_DEFAULT, 0x00, NULL);2612 gui_set_mode(GUI_MODE_PALETTE);2613 }2614 2615 //-------------------------------------------------------------------2616 2607 void gui_show_build_info(int arg) { 2617 2608 static char buf[192]; … … 2639 2630 2640 2631 //------------------------------------------------------------------- 2641 #ifdef OPT_GAME_REVERSI 2642 void gui_draw_reversi(int arg) { 2643 if ((mode_get()&MODE_MASK) != MODE_PLAY) { 2644 gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE, 2645 MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL); 2646 return; 2647 } 2648 2649 gui_set_mode(GUI_MODE_REVERSI); 2650 gui_reversi_init(); 2651 } 2652 #endif 2653 2654 //------------------------------------------------------------------- 2655 #ifdef OPT_GAME_SOKOBAN 2656 void gui_draw_sokoban(int arg) { 2657 if ((mode_get()&MODE_MASK) != MODE_PLAY) { 2658 gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE, 2659 MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL); 2660 return; 2661 } 2662 if ( gui_sokoban_init() ) 2663 gui_set_mode(GUI_MODE_SOKOBAN); 2664 } 2665 #endif 2666 //------------------------------------------------------------------- 2667 #ifdef OPT_GAME_CONNECT4 2668 void gui_draw_4wins(int arg) { 2669 if ((mode_get()&MODE_MASK) != MODE_PLAY) { 2670 gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE, 2671 MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL); 2672 return; 2673 } 2674 if ( gui_4wins_init() ) 2675 gui_set_mode(GUI_MODE_4WINS); 2676 } 2677 #endif 2678 //------------------------------------------------------------------- 2679 #ifdef OPT_GAME_MASTERMIND 2680 void gui_draw_mastermind(int arg) { 2681 if ((mode_get()&MODE_MASK) != MODE_PLAY) { 2682 gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE, 2683 MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL); 2684 return; 2685 } 2686 if ( gui_mastermind_init() ) 2687 gui_set_mode(GUI_MODE_MASTERMIND); 2688 } 2689 #endif 2690 //------------------------------------------------------------------- 2691 #ifdef OPT_DEBUGGING 2692 void gui_draw_debug(int arg) { 2693 // gui_debug_init(0x2510); 2694 // gui_debug_init(0x127E0); 2695 // gui_debug_init(0x7F5B8); 2696 // gui_debug_init(malloc(16)); 2697 gui_debug_init((void*)conf.mem_view_addr_init); 2698 } 2699 2700 //------------------------------------------------------------------- 2701 void gui_draw_bench(int arg) { 2702 gui_set_mode(GUI_MODE_BENCH); 2703 gui_bench_init(); 2704 } 2705 #endif 2706 //------------------------------------------------------------------- 2707 2632 void gui_menu_run_fltmodule(int arg) { 2633 module_run((char*)arg, 0, 0,0, UNLOAD_IF_ERR); 2634 } 2635 2636 //------------------------------------------------------------------- 2708 2637 void gui_draw_splash(char* logo, int logo_size) { 2709 2638 coord w, h, x, y; … … 2764 2693 //------------------------------------------------------------------- 2765 2694 void gui_draw_fselect(int arg) { 2766 gui_fselect_init(LANG_STR_FILE_BROWSER, "A", "A", NULL);2695 module_fselect_init(LANG_STR_FILE_BROWSER, "A", "A", NULL); 2767 2696 } 2768 2697 … … 2773 2702 } 2774 2703 void gui_grid_lines_load(int arg) { 2775 gui_fselect_init(LANG_STR_SELECT_GRID_FILE, conf.grid_lines_file, "A/CHDK/GRIDS", gui_grid_lines_load_selected);2704 module_fselect_init(LANG_STR_SELECT_GRID_FILE, conf.grid_lines_file, "A/CHDK/GRIDS", gui_grid_lines_load_selected); 2776 2705 } 2777 2706 … … 2789 2718 rbf_load_from_8x16(current_font); 2790 2719 rbf_set_codepage(conf.reader_codepage); 2791 gui_set_mode(GUI_MODE_READ); 2792 gui_read_init(fn); 2720 2721 unsigned int argv[] ={ (unsigned int)fn }; 2722 module_run("txtread.flt", 0, sizeof(argv)/sizeof(argv[0]), argv, UNLOAD_IF_ERR); 2793 2723 } 2794 2724 } 2795 2725 2796 2726 void gui_draw_read(int arg) { 2797 gui_fselect_init(LANG_STR_SELECT_TEXT_FILE, conf.reader_file, "A/CHDK/BOOKS", gui_draw_read_selected);2727 module_fselect_init_w_mode(LANG_STR_SELECT_TEXT_FILE, conf.reader_file, "A/CHDK/BOOKS", gui_draw_read_selected, 1); 2798 2728 void gui_fselect_set_key_redraw(int n); 2799 gui_fselect_set_key_redraw(1);2729 //gui_fselect_set_key_redraw(1); @tsv 2800 2730 } 2801 2731 … … 2818 2748 #ifdef OPT_EDGEOVERLAY 2819 2749 static void gui_load_edge_selected( const char* fn ) { 2820 if( fn )2821 load_edge_overlay(fn);2750 if( fn && module_edgeovr_load()) 2751 load_edge_overlay(fn); 2822 2752 } 2823 2753 2824 2754 void gui_menuproc_edge_save(int arg) { 2825 save_edge_overlay(); 2755 if ( module_edgeovr_load() ) 2756 save_edge_overlay(); 2826 2757 } 2827 2758 2828 2759 void gui_menuproc_edge_load(int arg) { 2829 gui_fselect_init(LANG_MENU_EDGE_LOAD, EDGE_SAVE_DIR, EDGE_SAVE_DIR, gui_load_edge_selected); 2830 } 2831 #endif 2832 2833 //------------------------------------------------------------------- 2834 #ifdef OPT_CALENDAR 2835 void gui_draw_calendar(int arg) { 2836 gui_set_mode(GUI_MODE_CALENDAR); 2837 gui_calendar_init(); 2838 } 2839 #endif 2760 module_fselect_init(LANG_MENU_EDGE_LOAD, EDGE_SAVE_DIR, EDGE_SAVE_DIR, gui_load_edge_selected); 2761 } 2762 #endif 2763 2840 2764 //------------------------------------------------------------------- 2841 2765 #ifdef OPT_TEXTREADER … … 2846 2770 } 2847 2771 void gui_draw_load_rbf(int arg) { 2848 gui_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.reader_rbf_file, "A/CHDK/FONTS", gui_draw_rbf_selected);2772 module_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.reader_rbf_file, "A/CHDK/FONTS", gui_draw_rbf_selected); 2849 2773 } 2850 2774 #endif … … 2860 2784 } 2861 2785 void gui_draw_load_menu_rbf(int arg) { 2862 gui_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.menu_rbf_file, "A/CHDK/FONTS", gui_draw_menu_rbf_selected);2786 module_fselect_init(LANG_STR_SELECT_FONT_FILE, conf.menu_rbf_file, "A/CHDK/FONTS", gui_draw_menu_rbf_selected); 2863 2787 } 2864 2788 … … 2872 2796 } 2873 2797 void gui_draw_load_symbol_rbf(int arg) { 2874 gui_fselect_init(LANG_STR_SELECT_SYMBOL_FILE, conf.menu_symbol_rbf_file, "A/CHDK/SYMBOLS", gui_draw_symbol_rbf_selected);2798 module_fselect_init(LANG_STR_SELECT_SYMBOL_FILE, conf.menu_symbol_rbf_file, "A/CHDK/SYMBOLS", gui_draw_symbol_rbf_selected); 2875 2799 } 2876 2800 … … 2884 2808 } 2885 2809 void gui_draw_load_lang(int arg) { 2886 gui_fselect_init(LANG_STR_SELECT_LANG_FILE, conf.lang_file, "A/CHDK/LANG", gui_draw_lang_selected);2887 } 2888 2889 int find_mnu(CMenu *curr_menu, int mnu, int count)2810 module_fselect_init(LANG_STR_SELECT_LANG_FILE, conf.lang_file, "A/CHDK/LANG", gui_draw_lang_selected); 2811 } 2812 2813 CMenuItem* find_mnu(CMenu *curr_menu, int itemid ) 2890 2814 { 2891 2815 int gui_menu_curr_item; 2816 CMenuItem* rv=0; 2817 2818 if ( itemid==0 ) 2819 return 0; 2892 2820 2893 2821 gui_menu_curr_item = 0; 2894 2822 while(curr_menu->menu[gui_menu_curr_item].text) { 2895 if (curr_menu->menu[gui_menu_curr_item].text == mnu){ 2896 user_submenu_items[count] = curr_menu->menu[gui_menu_curr_item]; 2897 return 1; 2823 if ( lang_strhash31(curr_menu->menu[gui_menu_curr_item].text) == itemid){ 2824 return (CMenuItem*) &(curr_menu->menu[gui_menu_curr_item]); 2898 2825 } 2899 2826 if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK) == MENUITEM_SUBMENU) 2900 if (curr_menu->menu[gui_menu_curr_item].text != LANG_MENU_USER_MENU) 2901 if (find_mnu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), mnu, count)) return 1; 2827 if (curr_menu->menu[gui_menu_curr_item].text != LANG_MENU_USER_MENU) { 2828 rv = find_mnu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), itemid); 2829 if ( rv ) 2830 return rv; 2831 } 2902 2832 gui_menu_curr_item++; 2903 2833 } … … 2912 2842 * conf.user_menu_vars only traks/saves the real user entries. 2913 2843 */ 2914 conf.user_menu_vars[x] = user_submenu_items[x+1].text;2844 conf.user_menu_vars[x] = lang_strhash31(user_submenu_items[x+1].text); 2915 2845 } 2916 2846 } 2917 2847 2918 2848 void user_menu_restore() { 2919 int x; 2849 int x; 2850 CMenuItem* item=0; 2851 2920 2852 for (x=0; x<USER_MENU_ITEMS; x++) { 2921 2853 /* … … 2923 2855 * conf.user_menu_vars only traks/saves the real user entries. 2924 2856 */ 2925 find_mnu(&root_menu, conf.user_menu_vars[x], x+1); 2857 item = find_mnu(&root_menu, conf.user_menu_vars[x]); 2858 if ( item ) 2859 user_submenu_items[x+1] = *item; 2926 2860 } 2927 2861 } -
trunk/core/gui_4wins.c
r1338 r1505 13 13 #include "gui_mbox.h" 14 14 #include "gui_4wins.h" 15 16 #include "module_load.h" 17 void gui_module_menu_kbd_process(); 18 19 gui_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 15 22 16 23 #define BORDER 20 … … 243 250 draw_txt_string(x, 4, lang_str(LANG_CONNECT4_HUMAN), TEXT_COLOR); 244 251 else 245 draw_txt_string(x, 4, PLATFORM, TEXT_COLOR);252 draw_txt_string(x, 4, "cam", TEXT_COLOR); 246 253 } 247 254 //------------------------------------------------------------------- … … 331 338 draw_mode(); 332 339 if(cur_player==2&&!mode_rival) set(); 340 341 gui_set_mode((unsigned int)&GUI_MODE_4WINS); 342 333 343 return 1; 334 344 } 345 346 int basic_module_init() { 347 return gui_4wins_init(); 348 } 349 335 350 //------------------------------------------------------------------- 336 351 void gui_4wins_kbd_process() … … 352 367 } 353 368 //------------------------------------------------------------------- 354 void gui_4wins_draw( ) {369 void gui_4wins_draw(int enforce_redraw) { 355 370 static char str[16]; 356 371 sprintf(str, "%3d%%", get_batt_perc()); … … 358 373 gui_osd_draw_clock(CAM_TS_BUTTON_BORDER+290,208,INFO_TEXT_COLOR); 359 374 } 375 376 extern int module_idx; 377 void gui_module_menu_kbd_process() { 378 gui_default_kbd_process_menu_btn(); 379 module_async_unload(module_idx); 380 } 381 382 /******************** Module Information structure ******************/ 383 384 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 385 sizeof(struct ModuleInfo), 386 387 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 388 ANY_PLATFORM_ALLOWED, // Specify platform dependency 389 0, // flag 390 -LANG_MENU_GAMES_CONNECT4, // Module name 391 1, 0, // Module version 392 (int32_t) "Game" 393 }; -
trunk/core/gui_4wins.h
r600 r1505 5 5 extern int gui_4wins_init(); 6 6 extern void gui_4wins_kbd_process(); 7 extern void gui_4wins_draw( );7 extern void gui_4wins_draw(int enforce_redraw); 8 8 9 9 //------------------------------------------------------------------- -
trunk/core/gui_bench.c
r1024 r1505 8 8 #include "gui_draw.h" 9 9 #include "gui_bench.h" 10 11 #include "module_load.h" 12 void gui_bench_draw_callback(int enforce_redraw); 13 void gui_bench_menu_kbd_process(); 14 15 gui_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 10 18 11 19 //------------------------------------------------------------------- … … 99 107 } 100 108 } 109 110 void gui_bench_draw_callback(int enforce_redraw) { 111 gui_bench_draw(); 112 } 113 101 114 102 115 //------------------------------------------------------------------- … … 158 171 } 159 172 160 x = open("A/BENCH.TMP", O_WRONLY|O_CREAT, 0777);173 x = safe_open("A/BENCH.TMP", O_WRONLY|STD_O_CREAT, 0777); 161 174 if (x>=0) { 162 175 bench.disk_write_raw_bps = 0; … … 170 183 } 171 184 172 x = open("A/BENCH.TMP", O_WRONLY|O_CREAT, 0777);185 x = safe_open("A/BENCH.TMP", O_WRONLY|STD_O_CREAT, 0777); 173 186 if (x>=0) { 174 187 bench.disk_write_mem_bps = 0; … … 183 196 184 197 if (buf) { 185 x = open("A/BENCH.TMP", O_WRONLY|O_CREAT, 0777);198 x = safe_open("A/BENCH.TMP", O_WRONLY|STD_O_CREAT, 0777); 186 199 if (x>=0) { 187 200 bench.disk_write_buf_bps = 0; … … 197 210 } 198 211 199 x = open("A/BENCH.TMP", O_RDONLY, 0777);212 x = safe_open("A/BENCH.TMP", O_RDONLY, 0777); 200 213 if (x>=0) { 201 214 bench.disk_read_buf_bps = 0; … … 229 242 //------------------------------------------------------------------- 230 243 244 int basic_module_init() { 245 gui_bench_init(); 246 gui_set_mode( (unsigned int)&GUI_MODE_BENCH ); 247 return 1; 248 } 249 250 extern int module_idx; 251 252 void gui_bench_menu_kbd_process() { 253 gui_default_kbd_process_menu_btn(); 254 module_async_unload(module_idx); 255 } 256 257 /******************** Module Information structure ******************/ 258 259 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 260 sizeof(struct ModuleInfo), 261 262 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 263 ANY_PLATFORM_ALLOWED, // Specify platform dependency 264 0, // flag 265 -LANG_MENU_DEBUG_BENCHMARK, // Module name 266 1, 0, // Module version 267 (int32_t) "Test camera low level perfomance" 268 }; -
trunk/core/gui_calendar.c
r1338 r1505 10 10 #include "gui_calendar.h" 11 11 12 #include "module_load.h" 13 void gui_calendar_menu_kbd_process(); 14 15 gui_handler GUI_MODE_CALENDAR = 16 /*GUI_MODE_CALENDAR*/ { gui_calendar_draw, gui_calendar_kbd_process, gui_calendar_menu_kbd_process, 0, GUI_MODE_MAGICNUM }; 17 12 18 //------------------------------------------------------------------- 13 19 #define TITLE_COLOR (MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)) … … 75 81 76 82 //------------------------------------------------------------------- 77 void gui_calendar_init() { 83 int basic_module_init() { 84 85 gui_set_mode( (unsigned int)&GUI_MODE_CALENDAR ); 86 78 87 calendar_goto_today(); 79 88 cal_w = FONT_WIDTH*4*7; … … 83 92 gui_calendar_initial_draw(); 84 93 need_redraw = 1; 94 return 1; 85 95 } 86 96 … … 110 120 need_redraw = 1; 111 121 break; 112 #if CAM_HAS_ERASE_BUTTON113 122 case KEY_ERASE: 114 #else115 123 case KEY_DISPLAY: 116 #endif117 124 calendar_goto_today(); 118 125 need_redraw = 1; … … 122 129 123 130 //------------------------------------------------------------------- 124 void gui_calendar_draw( ) {131 void gui_calendar_draw(int enforce_redraw) { 125 132 int x, y; 126 133 static char str[32]; … … 173 180 } 174 181 182 extern int module_idx; 183 184 void gui_calendar_menu_kbd_process() { 185 gui_default_kbd_process_menu_btn(); 186 module_async_unload(module_idx); 187 } 188 189 /******************** Module Information structure ******************/ 190 191 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 192 sizeof(struct ModuleInfo), 193 194 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 195 ANY_PLATFORM_ALLOWED, // Specify platform dependency 196 0, // flag 197 -LANG_MENU_MISC_CALENDAR, // Module name 198 1, 0, // Module version 199 0 200 }; -
trunk/core/gui_calendar.h
r515 r1505 5 5 extern void gui_calendar_init(); 6 6 extern void gui_calendar_kbd_process(); 7 extern void gui_calendar_draw( );7 extern void gui_calendar_draw(int enforce_redraw); 8 8 9 9 //------------------------------------------------------------------- -
trunk/core/gui_debug.c
r1024 r1505 8 8 #include "conf.h" 9 9 10 #include "module_load.h" 11 12 extern void gui_module_menu_kbd_process(); 13 int *conf_mem_view_addr_init; 14 15 gui_handler GUI_MODE_DEBUG = 16 /*GUI_MODE_DEBUG*/ { gui_debug_draw, gui_debug_kbd_process, gui_module_menu_kbd_process, 0, GUI_MODE_MAGICNUM }; 10 17 11 18 //------------------------------------------------------------------- … … 23 30 debug_cont_update = 1; 24 31 step = 4; 25 gui_set_mode( GUI_MODE_DEBUG);32 gui_set_mode((unsigned int)&GUI_MODE_DEBUG); 26 33 } 27 34 … … 30 37 int i; 31 38 32 if (!(addr<=(void*)MAXRAMADDR || addr>=(void*)ROMBASEADDR)) { addr = &dummy; }; 39 // non-significant check. remove to platform independency 40 // if (!(addr<=(void*)MAXRAMADDR || addr>=(void*)ROMBASEADDR)) { addr = &dummy; }; 33 41 34 42 sprintf(buf, "0x%08X (%10u)", *((unsigned int*)addr), *((unsigned int*)addr)); … … 56 64 57 65 //------------------------------------------------------------------- 58 void gui_debug_draw( ) {66 void gui_debug_draw(int enforce_redraw) { 59 67 switch (debug_to_draw) { 60 68 case 1: … … 87 95 gui_debug_draw_values(2, addr); 88 96 gui_debug_draw_values(8, *((void**)addr)); 89 conf.mem_view_addr_init = (long)addr;97 *conf_mem_view_addr_init = (long)addr; 90 98 91 99 if (debug_cont_update==0) debug_to_draw = 0; … … 142 150 143 151 //------------------------------------------------------------------- 152 153 extern int module_idx; 154 void gui_module_menu_kbd_process() { 155 gui_default_kbd_process_menu_btn(); 156 module_async_unload(module_idx); 157 } 158 159 160 // ========= MODULE INIT ================= 161 #include "module_load.h" 162 int module_idx=-1; 163 164 /***************** BEGIN OF AUXILARY PART ********************* 165 ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 166 **************************************************************/ 167 168 void* MODULE_EXPORT_LIST[] = { 169 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 170 /* 1 */ (void*)0 171 }; 172 173 174 //--------------------------------------------------------- 175 // PURPOSE: Bind module symbols with chdk. 176 // Required function 177 // PARAMETERS: pointer to chdk list of export 178 // RETURN VALUE: 1 error, 0 ok 179 //--------------------------------------------------------- 180 int _module_loader( void** chdk_export_list ) 181 { 182 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 183 return 1; 184 185 tConfigVal configVal; 186 CONF_BIND_INT(195, conf_mem_view_addr_init); 187 188 return 0; 189 } 190 191 192 193 //--------------------------------------------------------- 194 // PURPOSE: Finalize module operations (close allocs, etc) 195 // RETURN VALUE: 0-ok, 1-fail 196 //--------------------------------------------------------- 197 int _module_unloader() 198 { 199 return 0; 200 } 201 202 203 //--------------------------------------------------------- 204 // PURPOSE: Default action for simple modules (direct run) 205 // NOTE: Please comment this function if no default action and this library module 206 //--------------------------------------------------------- 207 int _module_run(int moduleidx, int argn, int* arguments) 208 { 209 module_idx=moduleidx; 210 211 void* adr; 212 213 if ( argn== 0 ) 214 adr =(char*)(*conf_mem_view_addr_init); 215 else if ( argn ==1) 216 adr = (char*)arguments[0]; 217 else { 218 module_async_unload(moduleidx); 219 return 1; 220 } 221 222 gui_debug_init(adr); 223 224 return 0; 225 } 226 227 228 /******************** Module Information structure ******************/ 229 #include "gui_lang.h" 230 231 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 232 sizeof(struct ModuleInfo), 233 234 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 235 ANY_PLATFORM_ALLOWED, // Specify platform dependency 236 0, // flag 237 -LANG_MENU_DEBUG_MEMORY_BROWSER, // Module name 238 1, 0, // Module version 239 (int32_t)"Simple memory content browser" 240 }; 241 242 /*************** END OF AUXILARY PART *******************/ -
trunk/core/gui_debug.h
r515 r1505 6 6 extern void gui_debug_init(void* st_addr); 7 7 extern void gui_debug_kbd_process(); 8 extern void gui_debug_draw( );8 extern void gui_debug_draw(int enforce_redraw); 9 9 10 10 //------------------------------------------------------------------- -
trunk/core/gui_draw.c
r1365 r1505 303 303 } 304 304 305 // Restore CANON_OSD 305 306 //------------------------------------------------------------------- 306 307 void draw_restore() { -
trunk/core/gui_draw.h
r1496 r1505 3 3 4 4 #include "camera.h" // ensure the camera defintion is loaded 5 6 #include "gui.h" // for color, coord definitions 7 8 9 // Common colors that are the same in all palettes 10 #define COLOR_TRANSPARENT 0x00 11 #define COLOR_BLACK 0xFF 5 12 6 13 //------------------------------------------------------------------- … … 11 18 12 19 //------------------------------------------------------------------- 13 14 // Common colors that are the same in all palettes15 #define COLOR_TRANSPARENT 0x0016 #define COLOR_BLACK 0xFF17 20 18 21 //------------------------------------------------------------------- -
trunk/core/gui_fselect.c
r1423 r1505 10 10 #include "gui_mpopup.h" 11 11 #include "gui_fselect.h" 12 #include " raw_merge.h"12 #include "modules.h" 13 13 #include "raw.h" 14 14 #include "conf.h" 15 15 #include "dng.h" 16 17 #include "module_load.h" 18 19 gui_handler GUI_MODE_FSELECT_MODULE = 20 /*GUI_MODE_FSELECT*/ { gui_fselect_draw, gui_fselect_kbd_process, gui_fselect_kbd_process, 0, GUI_MODE_MAGICNUM }; 21 22 extern int module_idx; 23 24 int *conf_sub_batch_prefix; 25 int *conf_sub_batch_ext; 26 27 struct librawop_sym* librawop_p; 28 16 29 17 30 //------------------------------------------------------------------- … … 47 60 static char selected_file[100]; // This full path to current file. So it is return value 48 61 static char buf[100]; 49 static enum Gui_Modegui_fselect_mode_old; // stored previous gui_mode62 static gui_mode_t gui_fselect_mode_old; // stored previous gui_mode 50 63 51 64 // basic element of file list … … 82 95 static int set_key_redraw_mode; // dirty hack: screen erase & mode restore done after(0) or before(1) call to fselect_on_select 83 96 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 112 static 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 84 129 //------------------------------------------------------------------- 85 130 static void fselect_goto_prev(int step) { … … 121 166 122 167 //------------------------------------------------------------------- 123 // Called from other gui functions to force redraw of menu124 void gui_fselect_force_redraw()125 {126 if (gui_get_mode() == GUI_MODE_FSELECT)127 {128 gui_fselect_redraw = 2;129 }130 }131 132 //-------------------------------------------------------------------133 168 static void gui_fselect_free_data() { 134 169 struct fitem *ptr = head, *prev; … … 173 208 //------------------------------------------------------------------- 174 209 static void gui_fselect_read_dir(const char* dir) { 175 DIR *d;176 struct dirent *de;177 static struct stat st;210 STD_DIR *d; 211 struct STD_dirent *de; 212 static struct STD_stat st; 178 213 struct fitem **ptr = &head, *prev = NULL; 179 214 int i; 180 215 181 216 gui_fselect_free_data(); 182 #ifdef CAM_DRYOS_2_3_R39217 //#ifdef CAM_DRYOS_2_3_R39 183 218 if(dir[0]=='A' && dir[1]==0) 184 d = opendir("A/");219 d = safe_opendir("A/"); 185 220 else 186 d = opendir(dir); 221 d = safe_opendir(dir); 222 /* //remove for platf independedncy. looks like sequence above is safe 187 223 #else 188 d = opendir(dir);224 d = safe_opendir(dir); 189 225 #endif 226 */ 190 227 if (d) { 191 de = readdir(d);228 de = safe_readdir(d); 192 229 while (de) { 193 230 if (de->d_name[0] != 0xE5 /* deleted entry */ && (de->d_name[0]!='.' || de->d_name[1]!=0)) { … … 199 236 strcpy((*ptr)->name, de->d_name); 200 237 sprintf(buf, "%s/%s", dir, de->d_name); 201 if (s tat(buf, &st)==0) {238 if (safe_stat(buf, &st)==0) { 202 239 (*ptr)->attr=st.st_attrib; 203 240 (*ptr)->size=st.st_size; … … 214 251 } 215 252 } 216 de = readdir(d);217 } 218 closedir(d);253 de = safe_readdir(d); 254 } 255 safe_closedir(d); 219 256 } 220 257 *ptr=NULL; … … 273 310 while (strlen(current_dir) > 0) 274 311 { 275 struct stat st;312 struct STD_stat st; 276 313 // check if input 'dir' exists 277 if (s tat(current_dir,&st) == 0)314 if (safe_stat(current_dir,&st) == 0) 278 315 { 279 316 // exists - check if it is a directory or file … … 305 342 306 343 //------------------------------------------------------------------- 307 void gui_fselect_init(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn)) { 344 void gui_fselect_init(int title, const char* prev_dir, const char* default_dir, void (*on_select)(const char *fn)) 345 { 308 346 int i; 309 347 … … 354 392 gui_fselect_mode_old = gui_get_mode(); 355 393 gui_fselect_redraw = 2; 356 gui_set_mode( GUI_MODE_FSELECT);394 gui_set_mode((unsigned int)&GUI_MODE_FSELECT_MODULE); 357 395 gui_fselect_set_key_redraw(0); 358 396 } … … 381 419 382 420 //------------------------------------------------------------------- 383 void gui_fselect_draw( ) {421 void gui_fselect_draw(int enforce_redraw) { 384 422 int i, j, off_name_x, off_size_x, off_time_x, off_body_x, off_body_y; 385 423 struct fitem *ptr; … … 389 427 color cl_markered = ((mode_get()&MODE_MASK) == MODE_REC)?COLOR_YELLOW:0x66; 390 428 color cl_marked, cl_selected; 429 430 if ( enforce_redraw ) 431 gui_fselect_redraw = 2; 391 432 392 433 if (gui_fselect_redraw) { … … 531 572 static void fselect_purge_cb(unsigned int btn) { 532 573 533 DIR *d, *d2, *d3, *d4;534 struct dirent *de, *de2, *de3, *de4;574 STD_DIR *d, *d2, *d3, *d4; 575 struct STD_dirent *de, *de2, *de3, *de4; 535 576 struct fitem *ptr, *ptr2; 536 577 char sub_dir[20], sub_dir_search[20]; … … 542 583 if (selected->name[0] == 'D' && selected->name[1] == 'C' && selected->name[2] == 'I' && selected->name[3] == 'M') { 543 584 sprintf(current_dir+strlen(current_dir), "/%s", selected->name); 544 d= opendir(current_dir);545 while ((de= readdir(d)) != NULL) {//Loop to find all Canon folders585 d=safe_opendir(current_dir); 586 while ((de=safe_readdir(d)) != NULL) {//Loop to find all Canon folders 546 587 if (de->d_name[0] != '.' && de->d_name[1] != '.') {//If item is not UpDir 547 588 sprintf(sub_dir, "%s/%s", current_dir, de->d_name); 548 d2= opendir(sub_dir);549 while ((de2= readdir(d2)) != NULL) {//Loop to find all the RAW files inside a Canon folder589 d2=safe_opendir(sub_dir); 590 while ((de2=safe_readdir(d2)) != NULL) {//Loop to find all the RAW files inside a Canon folder 550 591 if (de2->d_name[0] == 'C' || de2->d_name[9] == 'C') {//If file is RAW (Either CRW/CR2 prefix or file extension) 551 d3= opendir(current_dir);552 while ((de3= readdir(d3)) != NULL) {//Loop to find all Canon folders592 d3=safe_opendir(current_dir); 593 while ((de3=safe_readdir(d3)) != NULL) {//Loop to find all Canon folders 553 594 if (de3->d_name[0] != '.' && de3->d_name[1] != '.') {//If item is not UpDir 554 595 sprintf(sub_dir_search, "%s/%s", current_dir, de3->d_name); 555 d4= opendir(sub_dir_search);556 while ((de4= readdir(d4)) != NULL) {//Loop to find a corresponding JPG file inside a Canon folder596 d4=safe_opendir(sub_dir_search); 597 while ((de4=safe_readdir(d4)) != NULL) {//Loop to find a corresponding JPG file inside a Canon folder 557 598 if (de2->d_name[4] == de4->d_name[4] && de2->d_name[5] == de4->d_name[5] &&//If the four digits of the Canon number are the same 558 599 de2->d_name[6] == de4->d_name[6] && de2->d_name[7] == de4->d_name[7] && … … 562 603 } 563 604 } 564 closedir(d4);605 safe_closedir(d4); 565 606 } 566 607 } 567 closedir(d3);608 safe_closedir(d3); 568 609 //If no JPG found, delete RAW file 569 610 if (found == 0) { … … 578 619 } 579 620 } 580 closedir(d2);621 safe_closedir(d2); 581 622 } 582 623 } 583 closedir(d);624 safe_closedir(d); 584 625 i=strlen(current_dir); 585 626 while (current_dir[--i] != '/'); … … 589 630 else if (selected->name[3] == 'C') { 590 631 sprintf(current_dir+strlen(current_dir), "/%s", selected->name); 591 d= opendir(current_dir);592 while ((de= readdir(d)) != NULL) {//Loop to find all the RAW files inside the Canon folder632 d=safe_opendir(current_dir); 633 while ((de=safe_readdir(d)) != NULL) {//Loop to find all the RAW files inside the Canon folder 593 634 if (de->d_name[0] == 'C' || de->d_name[9] == 'C') {//If file is RAW (Either CRW/CR2 prefix or file extension) 594 d2= opendir(current_dir);595 while ((de2= readdir(d2)) != NULL) {//Loop to find a corresponding JPG file inside the Canon folder635 d2=safe_opendir(current_dir); 636 while ((de2=safe_readdir(d2)) != NULL) {//Loop to find a corresponding JPG file inside the Canon folder 596 637 if (de->d_name[4] == de2->d_name[4] && de->d_name[5] == de2->d_name[5] &&//If the four digits of the Canon number are the same 597 638 de->d_name[6] == de2->d_name[6] && de->d_name[7] == de2->d_name[7] && … … 601 642 } 602 643 } 603 closedir(d2);644 safe_closedir(d2); 604 645 //If no JPG found, delete RAW file 605 646 if (found == 0) { … … 614 655 } 615 656 } 616 closedir(d);657 safe_closedir(d); 617 658 i=strlen(current_dir); 618 659 while (current_dir[--i] != '/'); … … 652 693 //------------------------------------------------------------------- 653 694 static void fselect_delete_folder_cb(unsigned int btn) { 654 DIR *d;655 struct dirent *de;695 STD_DIR *d; 696 struct STD_dirent *de; 656 697 int i; 657 698 658 699 if (btn==MBOX_BTN_YES) { 659 700 sprintf(current_dir+strlen(current_dir), "/%s", selected->name); 660 d = opendir(current_dir);701 d = safe_opendir(current_dir); 661 702 if (d) { 662 de = readdir(d);703 de = safe_readdir(d); 663 704 while (de) { 664 705 if (de->d_name[0] != 0xE5 /* deleted entry */ && (de->d_name[0]!='.' || (de->d_name[1]!='.' && de->d_name[1]!=0) || (de->d_name[1]=='.' && de->d_name[2]!=0))) { … … 668 709 finished(); 669 710 } 670 de = readdir(d);671 } 672 closedir(d);711 de = safe_readdir(d); 712 } 713 safe_closedir(d); 673 714 } 674 715 started(); … … 778 819 gui_browser_progress_show(lang_str(LANG_FSELECT_PROGRESS_TITLE),i*100/marked_count); 779 820 sprintf(selected_file, "%s/%s", marked_dir, ptr->name); 780 fsrc = open(selected_file, O_RDONLY, 0777);821 fsrc = safe_open(selected_file, O_RDONLY, 0777); 781 822 if (fsrc>=0) { 782 823 sprintf(selected_file, "%s/%s", current_dir, ptr->name); 783 824 // trying to open for read to check if file exists 784 fdst = open(selected_file, O_RDONLY, 0777);825 fdst = safe_open(selected_file, O_RDONLY, 0777); 785 826 if (fdst<0) { 786 fdst = open(selected_file, O_WRONLY|O_CREAT, 0777);827 fdst = safe_open(selected_file, O_WRONLY|STD_O_CREAT, 0777); 787 828 if (fdst>=0) { 788 829 do { … … 874 915 875 916 //------------------------------------------------------------------- 917 static void fselect_chdk_replace_cb(unsigned int btn) { 918 int ss, sd = 0, fsrc, fdst, i=0; 919 register int *buf; 920 unsigned char fend; 921 static struct utimbuf t; 922 923 if (btn != MBOX_BTN_YES) return; 924 925 buf = umalloc(MARKED_BUF_SIZE); 926 sprintf(selected_file, "%s/%s", current_dir, selected->name); 927 fsrc = safe_open(selected_file, O_RDONLY, 0777); 928 if (fsrc>=0) { 929 strcpy(selected_file,"A/DISKBOOT.BIN"); 930 fdst = safe_open(selected_file, O_WRONLY|STD_O_CREAT|STD_O_TRUNC, 0777); 931 if (fdst>=0) { 932 do { 933 ss=read(fsrc, buf, MARKED_BUF_SIZE); 934 if (ss>0) sd=write(fdst, buf, ss); 935 } while (ss>0 && ss==sd); 936 close(fdst); 937 t.actime = t.modtime = selected->mtime; 938 utime(selected_file, &t); 939 //shutdown(); 940 gui_browser_progress_show("Please reboot",100); 941 } 942 if (fsrc>=0) close(fsrc); 943 } 944 ufree(buf); 945 } 946 947 //------------------------------------------------------------------- 876 948 static void fselect_marked_inverse_selection() { 877 949 struct fitem *ptr; … … 887 959 void process_raw_files(void){ 888 960 struct fitem *ptr; 889 if ((fselect_marked_count()>1) && raw_merge_start(raw_operation)) { 961 962 librawop_p=module_rawop_load(); 963 if (!librawop_p) 964 return; //exit if fail 965 966 if ((fselect_marked_count()>1) && librawop_p->raw_merge_start(raw_operation)) { 890 967 for (ptr=head; ptr; ptr=ptr->next) 891 968 if (ptr->marked && ptr->attr != 0xFF && !(ptr->attr & DOS_ATTR_DIRECTORY)) { 892 969 sprintf(selected_file, "%s/%s", current_dir, ptr->name); 893 raw_merge_add_file(selected_file);970 librawop_p->raw_merge_add_file(selected_file); 894 971 } 895 raw_merge_end();972 librawop_p->raw_merge_end(); 896 973 gui_fselect_read_dir(current_dir); 897 974 } … … 904 981 char *raw_subtract_dest; 905 982 if (btn != MBOX_BTN_YES) return; 983 984 librawop_p=module_rawop_load(); 985 if (!librawop_p) 986 return; //exit if fail 906 987 907 988 if(!(raw_subtract_from = malloc(300))) //3x full path … … 916 997 (strcmp(ptr->name,selected->name)) != 0) { 917 998 sprintf(raw_subtract_from,"%s/%s",current_dir,ptr->name); 918 sprintf(raw_subtract_dest,"%s/%s%s",current_dir,img_prefixes[ conf.sub_batch_prefix],ptr->name+4);919 strcpy(raw_subtract_dest + strlen(raw_subtract_dest) - 4,img_exts[ conf.sub_batch_ext]);999 sprintf(raw_subtract_dest,"%s/%s%s",current_dir,img_prefixes[*conf_sub_batch_prefix],ptr->name+4); 1000 strcpy(raw_subtract_dest + strlen(raw_subtract_dest) - 4,img_exts[*conf_sub_batch_ext]); 920 1001 // don't let users attempt to write one of the files being read 921 1002 if( strcmp(raw_subtract_dest,raw_subtract_from) != 0 && strcmp(raw_subtract_dest,raw_subtract_sub) != 0) { 922 raw_subtract(raw_subtract_from,raw_subtract_sub,raw_subtract_dest);1003 librawop_p->raw_subtract(raw_subtract_from,raw_subtract_sub,raw_subtract_dest); 923 1004 } 924 1005 } … … 955 1036 } 956 1037 //------------------------------------------------------------------- 957 #if DNG_SUPPORT1038 //#if DNG_SUPPORT 958 1039 void process_dng_to_raw_files(void){ 959 1040 struct fitem *ptr; … … 968 1049 sprintf(selected_file, "%s/%s", current_dir, ptr->name); 969 1050 gui_browser_progress_show(selected_file, (i++)*100/fselect_real_marked_count()) ; 970 convert_dng_to_chdk_raw(selected_file);1051 module_convert_dng_to_chdk_raw(selected_file); 971 1052 } 972 1053 } 973 1054 else { 974 1055 sprintf(selected_file, "%s/%s", current_dir, selected->name); 975 convert_dng_to_chdk_raw(selected_file);1056 module_convert_dng_to_chdk_raw(selected_file); 976 1057 } 977 1058 gui_fselect_read_dir(current_dir); 978 1059 } 979 #endif1060 //#endif 980 1061 981 1062 //------------------------------------------------------------------- … … 1047 1128 raw_prepare_develop(buf); 1048 1129 break; 1130 case MPOPUP_CHDK_REPLACE: 1131 gui_mbox_init((int)"Replacing CHDK", (int)"Do you want to replace current CHDK with this file", 1132 MBOX_TEXT_CENTER|MBOX_BTN_YES_NO|MBOX_DEF_BTN2, fselect_chdk_replace_cb); 1133 break; 1134 case MPOPUP_EDITOR: 1135 gui_mbox_init((int)"Editor", (int)"edit", MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 1136 break; 1049 1137 case MPOPUP_SUBTRACT: 1050 1138 { … … 1052 1140 break; 1053 1141 } 1054 #if DNG_SUPPORT1142 //#if DNG_SUPPORT 1055 1143 case MPOPUP_DNG_TO_CRW: 1056 1144 process_dng_to_raw_files(); 1057 1145 break; 1058 #endif1146 //#endif 1059 1147 } 1060 1148 gui_fselect_redraw = 2; … … 1062 1150 1063 1151 //------------------------------------------------------------------- 1064 static void exit_fselect(char* file)1152 void finalize_fselect() 1065 1153 { 1066 1154 gui_fselect_free_data(); 1067 1155 gui_fselect_marked_free_data(); 1156 module_rawop_unload(); 1157 } 1158 1159 static void exit_fselect(char* file) 1160 { 1161 finalize_fselect(); 1162 1068 1163 if (set_key_redraw_mode) 1069 1164 { … … 1074 1169 { 1075 1170 fselect_on_select(file); 1171 // if called mode will return control to filemanager - we need to redraw it 1172 gui_fselect_redraw = 2; 1076 1173 } 1077 1174 if (!set_key_redraw_mode) … … 1082 1179 } 1083 1180 1181 //------------------------------------------------------------------- 1084 1182 void gui_fselect_kbd_process() { 1085 1183 int i; … … 1140 1238 if(selected->size == hook_raw_size()) 1141 1239 i |= MPOPUP_RAW_DEVELOP; 1142 #if DNG_SUPPORT1240 //#if DNG_SUPPORT 1143 1241 if((fselect_marked_count()>1)||(selected->size > hook_raw_size())) 1144 1242 i |= MPOPUP_DNG_TO_CRW; 1145 #endif 1146 gui_mpopup_init(i, fselect_mpopup_cb); 1243 //#endif 1244 1245 if (selected->name[9] == 'B' && selected->name[10] == 'I' && selected->name[11] == 'N') //If item is DCIM folder 1246 i |= MPOPUP_CHDK_REPLACE; 1247 1248 module_mpopup_init( popup, i, fselect_mpopup_cb, 0); 1147 1249 } 1148 1250 break; … … 1161 1263 } else { 1162 1264 sprintf(selected_file, "%s/%s", current_dir, selected->name); 1265 1266 char *ext = strchr(selected->name,'.'); 1267 if ( ext && (ext[1]|0x20)=='f' && (ext[2]|0x20)=='l' && (ext[3]|0x20)=='t') { 1268 if (!fselect_on_select) { 1269 exit_fselect(0); 1270 module_run(selected_file, 0, 0,0, UNLOAD_IF_ERR); 1271 1272 break; 1273 } 1274 } 1275 1163 1276 exit_fselect(selected_file); 1277 module_async_unload(module_idx); 1164 1278 } 1165 1279 } 1166 1280 break; 1167 #if CAM_HAS_ERASE_BUTTON1168 1281 case KEY_ERASE: 1169 #else1170 1282 case KEY_DISPLAY: 1171 #endif1172 1283 if (selected && selected->attr != 0xFF) { 1173 1284 if (selected->attr & DOS_ATTR_DIRECTORY) { … … 1184 1295 // just free resource. callback called with NULL ptr 1185 1296 exit_fselect(0); 1186 break; 1187 } 1188 } 1189 1190 //------------------------------------------------------------------- 1297 module_async_unload(module_idx); 1298 break; 1299 } 1300 } 1301 1302 1303 1304 // ========= MODULE INIT ================= 1305 #include "module_load.h" 1306 int module_idx=-1; 1307 1308 /***************** BEGIN OF AUXILARY PART ********************* 1309 ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 1310 **************************************************************/ 1311 1312 void* MODULE_EXPORT_LIST[] = { 1313 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 1314 /* 1 */ (void*)0 1315 }; 1316 1317 1318 //--------------------------------------------------------- 1319 // PURPOSE: Bind module symbols with chdk. 1320 // Required function 1321 // PARAMETERS: pointer to chdk list of export 1322 // RETURN VALUE: 1 error, 0 ok 1323 //--------------------------------------------------------- 1324 int _module_loader( void** chdk_export_list ) 1325 { 1326 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 1327 return 1; 1328 1329 tConfigVal configVal; 1330 CONF_BIND_INT(209, conf_sub_batch_prefix); 1331 CONF_BIND_INT(210, conf_sub_batch_ext); 1332 1333 // Try to bind to generic gui mode alias 1334 if (!gui_bind_mode( GUI_MODE_FSELECT, &GUI_MODE_FSELECT_MODULE)) 1335 return 1; 1336 1337 return 0; 1338 } 1339 1340 1341 1342 //--------------------------------------------------------- 1343 // PURPOSE: Finalize module operations (close allocs, etc) 1344 // RETURN VALUE: 0-ok, 1-fail 1345 //--------------------------------------------------------- 1346 int _module_unloader() 1347 { 1348 finalize_fselect(); 1349 1350 //sanity clean to prevent accidentaly assign/restore guimode to unloaded module 1351 GUI_MODE_FSELECT_MODULE.magicnum = 0; 1352 1353 // Unbind generic alias 1354 gui_bind_mode( GUI_MODE_FSELECT, 0); 1355 1356 return 0; 1357 } 1358 1359 1360 //--------------------------------------------------------- 1361 // PURPOSE: Default action for simple modules (direct run) 1362 // NOTE: Please comment this function if no default action and this library module 1363 //--------------------------------------------------------- 1364 int _module_run(int moduleidx, int argn, int* arguments) 1365 { 1366 module_idx=moduleidx; 1367 1368 if ( argn!=0 && argn!=5 ) { 1369 module_async_unload(moduleidx); 1370 return 1; 1371 } 1372 1373 // Autounloading is unsafe because it should exists to catch finalization of mpopup 1374 module_set_flags(module_idx, MODULE_FLAG_DISABLE_AUTOUNLOAD); 1375 1376 if ( argn == 5 ) { 1377 gui_fselect_init( arguments[0], (const char*) arguments[1], (const char*) arguments[2], (void*)arguments[3]); 1378 gui_fselect_set_key_redraw(arguments[4]); 1379 } 1380 else 1381 gui_fselect_init(LANG_STR_FILE_BROWSER, "A", "A", NULL); 1382 1383 return 0; 1384 } 1385 1386 1387 /******************** Module Information structure ******************/ 1388 1389 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 1390 sizeof(struct ModuleInfo), 1391 1392 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 1393 ANY_PLATFORM_ALLOWED, // Specify platform dependency 1394 0, // flag 1395 -LANG_MENU_MISC_FILE_BROWSER, // Module name 1396 1, 0, // Module version 1397 0 1398 }; 1399 1400 /*************** END OF AUXILARY PART *******************/ -
trunk/core/gui_fselect.h
r1423 r1505 6 6 extern char* gui_fselect_result(); 7 7 extern void gui_fselect_kbd_process(); 8 extern void gui_fselect_draw( );8 extern void gui_fselect_draw(int enforce_redraw); 9 9 extern void gui_fselect_force_redraw(); 10 extern void finalize_fselect(); 10 11 //------------------------------------------------------------------- 11 12 #endif -
trunk/core/gui_mastermind.c
- Property svn:eol-style set to native
r1338 r1505 12 12 #include "gui_mastermind.h" 13 13 14 #include "module_load.h" 15 void gui_module_menu_kbd_process(); 16 17 gui_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 14 21 #define BORDER 20 15 22 #define RECT_SIZE 10 … … 21 28 int curr_y; 22 29 int answer[4]; 23 char colors[6] = { COLOR_HISTO_R_PLAY, COLOR_HISTO_G_PLAY, COLOR_HISTO_B_PLAY, COLOR_YELLOW, COLOR_WHITE, COLOR_BLACK };30 char colors[6]; 24 31 int curr_color[4]; 25 32 int GameGo; … … 133 140 for(i=0;i<4;i++) curr_color[i]=99; 134 141 142 gui_set_mode((unsigned int)&GUI_MODE_MASTERMIND); 135 143 return 1; 136 144 } 145 137 146 //------------------------------------------------------------------- 138 147 static void draw_box(color border) … … 217 226 } 218 227 //------------------------------------------------------------------- 219 void gui_mastermind_draw( ) {228 void gui_mastermind_draw(int enforce_redraw) { 220 229 unsigned long t; 221 230 static struct tm *ttm; … … 228 237 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); 229 238 } 239 240 241 int basic_module_init() { 242 colors[0] = COLOR_HISTO_R_PLAY; 243 colors[1] = COLOR_HISTO_G_PLAY; 244 colors[2] = COLOR_HISTO_B_PLAY; 245 colors[3] = COLOR_YELLOW; 246 colors[4] = COLOR_WHITE; 247 colors[5] = COLOR_BLACK; 248 249 return gui_mastermind_init(); 250 } 251 252 extern int module_idx; 253 void gui_module_menu_kbd_process() { 254 gui_default_kbd_process_menu_btn(); 255 module_async_unload(module_idx); 256 } 257 258 /******************** Module Information structure ******************/ 259 260 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 261 sizeof(struct ModuleInfo), 262 263 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 264 ANY_PLATFORM_ALLOWED, // Specify platform dependency 265 0, // flag 266 -LANG_MENU_GAMES_MASTERMIND,// Module name 267 1, 0, // Module version 268 (int32_t)"Game" 269 }; -
trunk/core/gui_mastermind.h
- Property svn:eol-style set to native
r649 r1505 5 5 extern int gui_mastermind_init(); 6 6 extern void gui_mastermind_kbd_process(); 7 extern void gui_mastermind_draw( );7 extern void gui_mastermind_draw(int enforce_redraw); 8 8 9 9 //------------------------------------------------------------------- -
trunk/core/gui_mbox.c
r1431 r1505 11 11 12 12 //------------------------------------------------------------------- 13 static enum Gui_Modegui_mbox_mode_old;13 static gui_mode_t gui_mbox_mode_old; 14 14 static const char* mbox_title; 15 15 static const char* mbox_msg; … … 86 86 87 87 //------------------------------------------------------------------- 88 void gui_mbox_draw( ) {88 void gui_mbox_draw(int enforce_redraw) { 89 89 if (mbox_to_draw) { 90 90 char c[MAX_LINES][MAX_WIDTH+1]; … … 172 172 173 173 //------------------------------------------------------------------- 174 175 void gui_browser_progress_show(const char* msg, const unsigned int perc) { 176 coord x=60, y=100; 177 unsigned int w=240, h=40, len; 178 179 draw_rect_shadow(x+1, y+1, x+w+1, y+h+1, COLOR_BLACK, 3); //shadow 180 draw_filled_rect(x, y, x+w, y+h, MAKE_COLOR(COLOR_GREY, COLOR_WHITE)); // main box 181 len = strlen(msg); 182 draw_string(x+((w-len*FONT_WIDTH)>>1), y+2, msg, MAKE_COLOR(COLOR_GREY, COLOR_WHITE)); //title text 183 draw_filled_rect(x+10, y+4+FONT_HEIGHT, x+w-10, y+h-10, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); // progress rect 184 draw_filled_rect(x+11, y+5+FONT_HEIGHT, x+11+(w-22)*perc/100, y+h-11, MAKE_COLOR(COLOR_RED, COLOR_RED)); // progress bar 185 } -
trunk/core/gui_mbox.h
r515 r1505 27 27 extern void gui_mbox_init(int title, int msg, const unsigned int flags, void (*on_select)(unsigned int btn)); 28 28 extern void gui_mbox_kbd_process(); 29 extern void gui_mbox_draw(); 29 extern void gui_mbox_draw(int enforce_redraw); 30 31 extern void gui_browser_progress_show(const char* msg, const unsigned int perc); 30 32 31 33 //------------------------------------------------------------------- -
trunk/core/gui_menu.c
r1425 r1505 8 8 #include "gui.h" 9 9 #include "gui_draw.h" 10 #include " gui_palette.h"10 #include "modules.h" 11 11 #include "gui_menu.h" 12 12 #include "gui_lang.h" … … 77 77 for(n = 0; curr_menu->menu[n].text; n++); 78 78 return n; 79 }80 81 //-------------------------------------------------------------------82 // Called from other gui functions to force redraw of menu83 void gui_menu_force_redraw()84 {85 if (gui_get_mode() == GUI_MODE_MENU)86 {87 gui_menu_redraw = 2;88 }89 79 } 90 80 … … 523 513 case MENUITEM_COLOR_FG: 524 514 case MENUITEM_COLOR_BG: 525 draw_restore();526 515 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); 529 517 gui_menu_redraw=2; 530 518 break; … … 680 668 681 669 //------------------------------------------------------------------- 682 void gui_menu_draw( ) {670 void gui_menu_draw(int enforce_redraw) { 683 671 static char tbuf[64]; 684 672 int i, j; 685 673 const char *ch = ""; 674 675 if ( enforce_redraw ) 676 gui_menu_redraw = 2; 686 677 687 678 if (gui_menu_redraw) -
trunk/core/gui_menu.h
r1407 r1505 50 50 typedef struct { 51 51 char symbol; 52 shorttitle;52 int title; 53 53 void (*on_change)(unsigned int item); 54 54 const CMenuItem *menu; … … 63 63 extern void gui_menu_init(CMenu *menu_ptr); 64 64 extern void gui_menu_kbd_process(); 65 extern void gui_menu_draw( );65 extern void gui_menu_draw(int enforce_redraw); 66 66 extern void mod_user_menu(CMenuItem curr_menu_item, int* gui_menu_add_item, int mod); 67 67 extern void gui_menu_force_redraw(); 68 68 //------------------------------------------------------------------- 69 70 // declared in gui.c 71 extern CMenuItem* find_mnu(CMenu *curr_menu, int item); 72 69 73 #endif -
trunk/core/gui_mpopup.c
r1407 r1505 9 9 #include "gui_mpopup.h" 10 10 11 #include "module_load.h" 12 13 extern int module_idx; 14 15 gui_handler GUI_MODE_MPOPUP_MODULE = 16 /*GUI_MODE_MPOPUP*/ { gui_mpopup_draw, gui_mpopup_kbd_process, gui_mpopup_kbd_process, GUI_MODE_FLAG_NORESTORE_ON_SWITCH, GUI_MODE_MAGICNUM }; 17 11 18 // Simple popup menu. No title, no separators, only processing items 12 19 13 20 //------------------------------------------------------------------- 14 static enum Gui_Modegui_mpopup_mode_old;21 static gui_mode_t gui_mpopup_mode_old; 15 22 static char mpopup_to_draw; 16 23 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_SUPPORT32 { MPOPUP_DNG_TO_CRW, (int)"DNG -> CHDK RAW"},33 #endif34 };35 36 #define ACTIONSNUM (sizeof(actions)/sizeof(actions[0]))37 24 #define MAX_ACTIONS 10 25 26 struct mpopup_item* actions; 38 27 39 28 static int mpopup_actions[MAX_ACTIONS]; // Content of raised popupmenu … … 45 34 46 35 //------------------------------------------------------------------- 47 void gui_mpopup_init(const unsigned int flags, void (*on_select)(unsigned int actn)) { 36 void gui_mpopup_init(struct mpopup_item* popup_actions, const unsigned int flags, void (*on_select)(unsigned int actn), int mode) 37 { 48 38 int i; 49 39 50 40 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) { 52 43 if (flags & MPOPUP_MASK & actions[i].flag) 53 44 mpopup_actions[mpopup_actions_num++] = i; 54 45 } 55 if (mpopup_actions_num == 0) 46 if (mpopup_actions_num == 0) { 56 47 on_select(MPOPUP_CANCEL); 48 return; 49 } 57 50 58 51 mpopup_actions_active = 0; … … 61 54 mpopup_to_draw = 1; 62 55 mpopup_on_select = on_select; 63 gui_set_mode( GUI_MODE_MPOPUP);56 gui_set_mode((unsigned int)&GUI_MODE_MPOPUP_MODULE); 64 57 } 65 58 … … 85 78 86 79 //------------------------------------------------------------------- 87 void gui_mpopup_draw( ) {80 void gui_mpopup_draw(int enforce_redraw) { 88 81 if (mpopup_to_draw) { 89 82 int i; … … 114 107 115 108 //------------------------------------------------------------------- 109 void exit_mpopup(int action) 110 { 111 gui_set_mode(gui_mpopup_mode_old); 112 if (mpopup_on_select) 113 mpopup_on_select(action); 114 mpopup_on_select=0; 115 } 116 117 //------------------------------------------------------------------- 116 118 void gui_mpopup_kbd_process() { 117 119 switch (kbd_get_clicked_key() | get_jogdial_direction()) { … … 131 133 case KEY_LEFT: 132 134 kbd_reset_autoclicked_key(); 133 gui_set_mode(gui_mpopup_mode_old); 134 if (mpopup_on_select) 135 mpopup_on_select(MPOPUP_CANCEL); 135 exit_mpopup(MPOPUP_CANCEL); 136 module_async_unload(module_idx); 136 137 break; 137 138 case KEY_SET: 138 139 kbd_reset_autoclicked_key(); 139 gui_set_mode(gui_mpopup_mode_old); 140 if (mpopup_on_select) 141 mpopup_on_select(actions[mpopup_actions[mpopup_actions_active]].flag); 142 break; 143 } 144 } 145 146 //------------------------------------------------------------------- 147 void gui_browser_progress_show(const char* msg, const unsigned int perc) { 148 coord x=60, y=100; 149 unsigned int w=240, h=40, len; 150 151 draw_rect_shadow(x+1, y+1, x+w+1, y+h+1, COLOR_BLACK, 3); //shadow 152 draw_filled_rect(x, y, x+w, y+h, MAKE_COLOR(COLOR_GREY, COLOR_WHITE)); // main box 153 len = strlen(msg); 154 draw_string(x+((w-len*FONT_WIDTH)>>1), y+2, msg, MAKE_COLOR(COLOR_GREY, COLOR_WHITE)); //title text 155 draw_filled_rect(x+10, y+4+FONT_HEIGHT, x+w-10, y+h-10, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); // progress rect 156 draw_filled_rect(x+11, y+5+FONT_HEIGHT, x+11+(w-22)*perc/100, y+h-11, MAKE_COLOR(COLOR_RED, COLOR_RED)); // progress bar 157 } 140 exit_mpopup(actions[mpopup_actions[mpopup_actions_active]].flag); 141 module_async_unload(module_idx); 142 break; 143 } 144 } 145 146 //------------------------------------------------------------------- 147 148 // ========= MODULE INIT ================= 149 150 int module_idx=-1; 151 152 /***************** BEGIN OF AUXILARY PART ********************* 153 ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 154 **************************************************************/ 155 156 void* MODULE_EXPORT_LIST[] = { 157 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 158 /* 1 */ (void*)0 159 }; 160 161 162 //--------------------------------------------------------- 163 // PURPOSE: Bind module symbols with chdk. 164 // Required function 165 // PARAMETERS: pointer to chdk list of export 166 // RETURN VALUE: 1 error, 0 ok 167 //--------------------------------------------------------- 168 int _module_loader( void** chdk_export_list ) 169 { 170 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 171 return 1; 172 173 // Try to bind to generic gui mode alias 174 if (!gui_bind_mode( GUI_MODE_MPOPUP, &GUI_MODE_MPOPUP_MODULE)) 175 return 1; 176 177 return 0; 178 } 179 180 181 182 //--------------------------------------------------------- 183 // PURPOSE: Finalize module operations (close allocs, etc) 184 // RETURN VALUE: 0-ok, 1-fail 185 //--------------------------------------------------------- 186 int _module_unloader() 187 { 188 if (mpopup_on_select) 189 mpopup_on_select(MPOPUP_CANCEL); 190 191 //sanity clean to prevent accidentaly assign/restore guimode to unloaded module 192 GUI_MODE_MPOPUP_MODULE.magicnum = 0; 193 194 // unbind generic alias 195 gui_bind_mode( GUI_MODE_MPOPUP, 0 ); 196 197 return 0; 198 } 199 200 201 //--------------------------------------------------------- 202 // PURPOSE: Default action for simple modules (direct run) 203 // NOTE: Please comment this function if no default action and this library module 204 //--------------------------------------------------------- 205 int _module_run(int moduleidx, int argn, int* arguments) 206 { 207 module_idx=moduleidx; 208 209 if ( argn!=4) { 210 module_async_unload(moduleidx); 211 return 1; 212 } 213 214 // Currently only old (0) mode is supported 215 // This is for load error if newer version is required 216 if (arguments[3]!=0) 217 return 1; 218 219 gui_mpopup_init( (struct mpopup_item*)arguments[0], (const unsigned int)arguments[1], (void*) arguments[2], arguments[3]); 220 221 222 return 0; 223 } 224 225 226 /******************** Module Information structure ******************/ 227 228 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 229 sizeof(struct ModuleInfo), 230 231 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 232 ANY_PLATFORM_ALLOWED, // Specify platform dependency 233 MODULEINFO_FLAG_SYSTEM, // flag 234 (int32_t)"Popup menu module", // Module name 235 1, 0, // Module version 236 0 237 }; 238 239 /*************** END OF AUXILARY PART *******************/ -
trunk/core/gui_mpopup.h
r666 r1505 3 3 4 4 //------------------------------------------------------------------- 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 8 struct mpopup_item { 9 unsigned int flag; 10 int text; 11 }; 18 12 19 13 //------------------------------------------------------------------- 20 extern void gui_mpopup_init( const unsigned int flags, void (*on_select)(unsigned int actn));14 extern void gui_mpopup_init(struct mpopup_item* popup_actions, const unsigned int flags, void (*on_select)(unsigned int actn), int mode); 21 15 extern 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); 16 extern void gui_mpopup_draw(int enforce_redraw); 25 17 26 18 //------------------------------------------------------------------- -
trunk/core/gui_osd.c
r1499 r1505 105 105 106 106 //------------------------------------------------------------------- 107 void gui_osd_draw( ) {107 void gui_osd_draw(int enforce_redraw) { 108 108 if (osd_to_draw) { 109 109 int i; -
trunk/core/gui_osd.h
r683 r1505 36 36 extern void gui_osd_init(); 37 37 extern void gui_osd_kbd_process(); 38 extern void gui_osd_draw( );38 extern void gui_osd_draw(int enforce_redraw); 39 39 40 40 extern void gui_osd_draw_histo(); -
trunk/core/gui_palette.c
r1338 r1505 10 10 #include "gui_palette.h" 11 11 12 13 #include "module_load.h" 14 void gui_module_menu_kbd_process(); 15 16 gui_handler GUI_MODE_PALETTE_MODULE = 17 /*GUI_MODE_PALETTE*/ { gui_palette_draw, gui_palette_kbd_process, gui_module_menu_kbd_process, 0, GUI_MODE_MAGICNUM }; 18 12 19 //------------------------------------------------------------------- 13 20 static color cl; … … 18 25 //------------------------------------------------------------------- 19 26 void gui_palette_init(int mode, color st_color, void (*on_select)(color clr)) { 27 draw_restore(); 20 28 cl = st_color; 21 29 palette_mode = mode; 22 30 palette_on_select = on_select; 23 31 gui_palette_redraw = 1; 32 gui_set_mode((unsigned int)&GUI_MODE_PALETTE_MODULE); 24 33 } 25 34 … … 49 58 if (palette_on_select) 50 59 palette_on_select(cl); 51 gui_ set_mode(GUI_MODE_MENU);60 gui_module_menu_kbd_process(); 52 61 } 53 62 break; … … 64 73 #define DISP_BOTTOM (FONT_HEIGHT + BORDER_SIZE + CELL_SIZE * 16) 65 74 66 void gui_palette_draw( ) {75 void gui_palette_draw(int enforce_redraw) { 67 76 unsigned int x, y, xl, xr; 68 77 char f=0; … … 108 117 } 109 118 119 extern int module_idx; 120 void 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" 127 int module_idx=-1; 128 129 /***************** BEGIN OF AUXILARY PART ********************* 130 ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 131 **************************************************************/ 132 133 void* MODULE_EXPORT_LIST[] = { 134 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 135 /* 1 */ (void*)0 136 }; 137 138 139 //--------------------------------------------------------- 140 // PURPOSE: Bind module symbols with chdk. 141 // Required function 142 // PARAMETERS: pointer to chdk list of export 143 // RETURN VALUE: 1 error, 0 ok 144 //--------------------------------------------------------- 145 int _module_loader( void** chdk_export_list ) 146 { 147 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 148 return 1; 149 150 // Try to bind to generic gui mode alias 151 if (!gui_bind_mode( GUI_MODE_PALETTE, &GUI_MODE_PALETTE_MODULE)) 152 return 1; 153 154 return 0; 155 } 156 157 158 159 //--------------------------------------------------------- 160 // PURPOSE: Finalize module operations (close allocs, etc) 161 // RETURN VALUE: 0-ok, 1-fail 162 //--------------------------------------------------------- 163 int _module_unloader() 164 { 165 //sanity clean to prevent accidentaly assign/restore guimode to unloaded module 166 GUI_MODE_PALETTE_MODULE.magicnum = 0; 167 168 // unbind generic alias 169 gui_bind_mode( GUI_MODE_PALETTE, 0); 170 171 return 0; 172 } 173 174 175 //--------------------------------------------------------- 176 // PURPOSE: Default action for simple modules (direct run) 177 // NOTE: Please comment this function if no default action and this library module 178 //--------------------------------------------------------- 179 int _module_run(int moduleidx, int argn, int* arguments) 180 { 181 module_idx=moduleidx; 182 183 if ( argn!=0 && argn!=3) { 184 module_async_unload(moduleidx); 185 return 1; 186 } 187 188 if ( argn==3 ) 189 gui_palette_init( arguments[0], (color)arguments[1], (void*)arguments[2]); 190 else 191 gui_palette_init( PALETTE_MODE_DEFAULT, 0x00, NULL ); 192 193 return 0; 194 } 195 196 /******************** Module Information structure ******************/ 197 198 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 199 sizeof(struct ModuleInfo), 200 201 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 202 ANY_PLATFORM_ALLOWED, // Specify platform dependency 203 0, // flag 204 (int32_t)"Palette", // Module name 205 1, 0, // Module version 206 0 207 }; 208 209 /*************** END OF AUXILARY PART *******************/ -
trunk/core/gui_palette.h
r515 r1505 12 12 extern void gui_palette_init(int mode, color st_color, void (*on_select)(color clr)); 13 13 extern void gui_palette_kbd_process(); 14 extern void gui_palette_draw( );14 extern void gui_palette_draw(int enforce_redraw); 15 15 16 16 //------------------------------------------------------------------- -
trunk/core/gui_read.c
r1338 r1505 11 11 12 12 13 #include "module_load.h" 14 15 extern void gui_read_kbd_process_menu_btn(); 16 17 int *conf_reader_autoscroll; 18 int *conf_reader_autoscroll_delay; 19 int *conf_reader_pos; 20 int *conf_reader_wrap_by_words; 21 color *conf_reader_color; 22 char *conf_reader_file; 23 char *conf_menu_rbf_file; 24 25 gui_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 13 28 //------------------------------------------------------------------- 14 29 static int read_file; … … 23 38 static int pause; 24 39 40 static 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 25 43 //------------------------------------------------------------------- 26 44 static void gui_read_draw_batt() { … … 42 60 //------------------------------------------------------------------- 43 61 static 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 infoline62 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 45 63 } 46 64 47 65 //------------------------------------------------------------------- 48 66 int gui_read_init(const char* file) { 49 static struct stat st;50 read_file = open(file, O_RDONLY, 0777);51 if (strcmp(file, conf .reader_file)!=0) {52 conf.reader_pos = 0;53 strcpy(conf .reader_file, file);67 static struct STD_stat st; 68 read_file = safe_open(file, O_RDONLY, 0777); 69 if (strcmp(file, conf_reader_file)!=0) { 70 *conf_reader_pos = 0; 71 strcpy(conf_reader_file, file); 54 72 } 55 73 read_on_screen = 0; 56 read_file_size = (read_file>=0 && s tat((char*)file, &st)==0)?st.st_size:0;57 if (read_file_size<= conf.reader_pos) {58 conf.reader_pos = 0;74 read_file_size = (read_file>=0 && safe_stat((char*)file, &st)==0)?st.st_size:0; 75 if (read_file_size<=*conf_reader_pos) { 76 *conf_reader_pos = 0; 59 77 } 60 78 pause = 0; … … 66 84 last_time = get_tick_count(); 67 85 86 reader_is_active=1; 87 gui_set_mode((unsigned int)&GUI_MODE_READ); 88 68 89 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)); 70 91 71 92 gui_read_draw_scroll_indicator(); … … 77 98 //------------------------------------------------------------------- 78 99 static 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)); 80 101 xx = x; 81 102 yy += rbf_font_height(); … … 88 109 89 110 //------------------------------------------------------------------- 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;111 void 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; 93 114 read_to_draw = 1; 94 115 } … … 98 119 xx=x; yy=y; 99 120 100 lseek(read_file, conf.reader_pos, SEEK_SET);121 lseek(read_file, *conf_reader_pos, SEEK_SET); 101 122 read_on_screen=0; 102 123 … … 106 127 read_goto_next_line(); 107 128 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)); 109 130 break; 110 131 } … … 123 144 // no break here 124 145 default: 125 if ( conf.reader_wrap_by_words) {146 if (*conf_reader_wrap_by_words) { 126 147 if (buffer[i] == ' ') { 127 148 new_word = 1; … … 153 174 continue; 154 175 } 155 xx+=rbf_draw_char(xx, yy, buffer[i], conf.reader_color);176 xx+=rbf_draw_char(xx, yy, buffer[i], *conf_reader_color); 156 177 break; 157 178 } … … 165 186 } 166 187 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); 168 189 buffer[screen_width/FONT_WIDTH]=0; 169 190 draw_txt_string((CAM_TS_BUTTON_BORDER/FONT_WIDTH), 0, buffer, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline … … 174 195 n=i*read_on_screen/read_file_size; // bar height 175 196 if (n<20) n=20; 176 i=(i-n)* conf.reader_pos/read_file_size; // top pos197 i=(i-n)**conf_reader_pos/read_file_size; // top pos 177 198 draw_filled_rect(x+w+6+2, y+1, x+w+6+6, y+1+i, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 178 199 draw_filled_rect(x+w+6+2, y+i+n, x+w+6+6, y+h-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); … … 197 218 case KEY_UP: 198 219 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; 202 223 read_to_draw = 1; 203 224 } … … 208 229 case KEY_RIGHT: 209 230 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; 212 233 read_to_draw = 1; 213 234 } … … 221 242 break; 222 243 case KEY_MENU: 223 if (read_file >= 0) { 244 gui_read_kbd_leave(); 245 break; 246 } 247 } 248 249 extern int module_idx; 250 251 //------------------------------------------------------------------- 252 // Menu button handled for text reader 253 void 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 260 void 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) { 224 270 close(read_file); 225 271 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" 277 int module_idx=-1; 278 279 /***************** BEGIN OF AUXILARY PART ********************* 280 ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 281 **************************************************************/ 282 283 void* MODULE_EXPORT_LIST[] = { 284 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 285 /* 1 */ (void*)0 286 }; 287 288 289 //--------------------------------------------------------- 290 // PURPOSE: Bind module symbols with chdk. 291 // Required function 292 // PARAMETERS: pointer to chdk list of export 293 // RETURN VALUE: 1 error, 0 ok 294 //--------------------------------------------------------- 295 int _module_loader( void** chdk_export_list ) 296 { 297 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 298 return 1; 299 300 tConfigVal configVal; 301 CONF_BIND_COLOR( 31, conf_reader_color ); 302 CONF_BIND_STR( 38, conf_reader_file ); 303 CONF_BIND_INT( 39, conf_reader_pos ); 304 CONF_BIND_INT( 43, conf_reader_autoscroll ); 305 CONF_BIND_INT( 44, conf_reader_autoscroll_delay ); 306 CONF_BIND_INT( 61, conf_reader_wrap_by_words ); 307 CONF_BIND_STR( 66, conf_menu_rbf_file ); 308 309 return 0; 310 } 311 312 313 314 //--------------------------------------------------------- 315 // PURPOSE: Finalize module operations (close allocs, etc) 316 // RETURN VALUE: 0-ok, 1-fail 317 //--------------------------------------------------------- 318 int _module_unloader() 319 { 320 // We should make "leave sequence" to restore font settings 321 gui_read_kbd_leave(); 322 323 GUI_MODE_READ.magicnum = 0; //sanity clean to prevent accidentaly assign/restore guimode to unloaded module 324 325 return 0; 326 } 327 328 329 //--------------------------------------------------------- 330 // PURPOSE: Default action for simple modules (direct run) 331 // NOTE: Please comment this function if no default action and this library module 332 //--------------------------------------------------------- 333 int _module_run(int moduleidx, int argn, int* arguments) 334 { 335 module_idx=moduleidx; 336 337 if ( argn!=1 || arguments[0]==0) { 338 module_async_unload(moduleidx); 339 return 1; 340 } 341 342 char* fn=(char*)arguments[0]; 343 gui_read_init(fn); 344 345 return 0; 346 } 347 348 349 /******************** Module Information structure ******************/ 350 351 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 352 sizeof(struct ModuleInfo), 353 354 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 355 ANY_PLATFORM_ALLOWED, // Specify platform dependency 356 MODULEINFO_FLAG_SYSTEM, // flag 357 (int32_t)"Text reader", // Module name 358 1, 0, // Module version 359 0 360 }; 361 362 /*************** END OF AUXILARY PART *******************/ -
trunk/core/gui_read.h
r515 r1505 7 7 extern int gui_read_init(const char* file); 8 8 extern void gui_read_kbd_process(); 9 extern void gui_read_draw(); 9 extern void gui_read_draw(int enforce_redraw); 10 extern void gui_read_kbd_leave(); 10 11 11 12 //------------------------------------------------------------------- -
trunk/core/gui_reversi.c
r1338 r1505 10 10 #include "gui_mbox.h" 11 11 #include "gui_reversi.h" 12 13 #include "module_load.h" 14 void gui_module_menu_kbd_process(); 15 16 gui_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 12 19 13 20 //------------------------------------------------------------------- … … 344 351 345 352 //------------------------------------------------------------------- 346 void gui_reversi_init() { 353 int basic_module_init() { 354 gui_set_mode((unsigned int)&GUI_MODE_REVERSI); 347 355 InitMainWindow(); 348 356 NewGame(); 349 357 need_redraw_all = 1; 358 return 1; 350 359 } 351 360 … … 376 385 need_redraw = 1; 377 386 break; 378 #if CAM_HAS_ERASE_BUTTON379 387 case KEY_ERASE: 380 #else381 388 case KEY_DISPLAY: 382 #endif383 389 if (InGame) 384 390 Computer=COMPUTER_ONLY; … … 387 393 need_redraw = 1; 388 394 break; 389 #if CAM_HAS_ERASE_BUTTON 390 case KEY_DISPLAY: 391 gui_mbox_init(LANG_MBOX_ABOUT_TITLE, (int)"REVERSI\n(c) GrAnd, 2007", MBOX_TEXT_CENTER, NULL); 392 need_redraw_all = 1; 393 break; 394 #endif 395 } 396 } 397 398 //------------------------------------------------------------------- 399 void gui_reversi_draw() { 395 } 396 } 397 398 //------------------------------------------------------------------- 399 void gui_reversi_draw(int enforce_redraw) { 400 400 if (need_redraw_all) { 401 401 need_redraw_all = 0; … … 415 415 } 416 416 417 418 extern int module_idx; 419 void gui_module_menu_kbd_process() { 420 gui_default_kbd_process_menu_btn(); 421 module_async_unload(module_idx); 422 } 423 424 425 /******************** Module Information structure ******************/ 426 427 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 428 sizeof(struct ModuleInfo), 429 430 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 431 ANY_PLATFORM_ALLOWED, // Specify platform dependency 432 0, // flag 433 -LANG_MENU_GAMES_REVERSI, // Module name 434 1, 0, // Module version 435 (int32_t)"Game" 436 }; -
trunk/core/gui_reversi.h
r515 r1505 5 5 extern void gui_reversi_init(); 6 6 extern void gui_reversi_kbd_process(); 7 extern void gui_reversi_draw( );7 extern void gui_reversi_draw(int enforce_redraw); 8 8 9 9 //------------------------------------------------------------------- -
trunk/core/gui_snake.c
r1467 r1505 320 320 321 321 break; 322 #if CAM_HAS_ERASE_BUTTON323 322 case KEY_ERASE: 324 #else325 323 case KEY_DISPLAY: 326 #endif327 324 break; 328 325 } … … 447 444 **************************************************************/ 448 445 449 int _chdk_required_ver = 1; // minimal required chdk build. 0-no limitation450 int _chdk_required_platfid = 0; // platform-specific module. 0-no limitation451 452 446 void* MODULE_EXPORT_LIST[] = { 453 447 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, … … 497 491 } 498 492 493 /******************** Module Information structure ******************/ 494 495 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 496 sizeof(struct ModuleInfo), 497 498 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 499 ANY_PLATFORM_ALLOWED, // Specify platform dependency 500 0, // flag 501 (int32_t)"Snake", // Module name 502 1, 0, // Module version 503 (int32_t)"Game" 504 }; 505 499 506 500 507 /*************** END OF AUXILARY PART *******************/ -
trunk/core/gui_sokoban.c
r1338 r1505 11 11 #include "gui_mbox.h" 12 12 #include "gui_sokoban.h" 13 14 #include "module_load.h" 15 void gui_module_menu_kbd_process(); 16 17 int *conf_sokoban_level; 18 19 gui_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 13 22 14 23 //------------------------------------------------------------------- … … 197 206 198 207 free(buf); 199 conf.sokoban_level = lvl;208 *conf_sokoban_level = lvl; 200 209 moves = 0; 201 210 sokoban_undo_reset(); … … 215 224 //------------------------------------------------------------------- 216 225 static 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); 219 228 need_redraw_all = 1; 220 229 } … … 266 275 char *buf,*p; 267 276 FILE *fd; 268 struct stat st;269 270 if (s tat((char *)level_file_name,&st) != 0 || st.st_size==0)277 struct STD_stat st; 278 279 if (safe_stat((char *)level_file_name,&st) != 0 || st.st_size==0) 271 280 return 0; 272 281 … … 313 322 return 0; 314 323 } 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; 317 326 } 318 327 cell_size = screen_height/FIELD_HEIGHT; 319 sokoban_set_level( conf.sokoban_level);328 sokoban_set_level(*conf_sokoban_level); 320 329 // if the file is no longer readable, set_level will set this 321 330 if(!num_levels) { … … 323 332 } 324 333 need_redraw_all = 1; 334 335 gui_set_mode((unsigned int)&GUI_MODE_SOKOBAN); 325 336 return 1; 326 337 } … … 358 369 need_redraw = 1; 359 370 break; 360 #if CAM_HAS_ERASE_BUTTON361 371 case KEY_ERASE: 362 #else363 372 case KEY_DISPLAY: 364 #endif 365 sokoban_set_level(conf.sokoban_level); 373 sokoban_set_level(*conf_sokoban_level); 366 374 need_redraw_all = 1; 367 375 break; 368 #if CAM_HAS_ERASE_BUTTON 369 case KEY_DISPLAY: 370 gui_mbox_init(LANG_MBOX_ABOUT_TITLE, (int)"SOKOBAN\n(c) GrAnd, 2007", MBOX_TEXT_CENTER, NULL); 371 need_redraw = 1; 372 break; 373 #endif 374 } 375 } 376 377 //------------------------------------------------------------------- 378 void gui_sokoban_draw() { 376 } 377 } 378 379 //------------------------------------------------------------------- 380 void gui_sokoban_draw(int enforce_redraw) { 379 381 int y, x; 380 382 static char str[16]; … … 420 422 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); 421 423 422 sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_LEVEL), conf.sokoban_level+1);424 sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_LEVEL), *conf_sokoban_level+1); 423 425 draw_string(CAM_TS_BUTTON_BORDER+cell_size*FIELD_WIDTH+2, 8, str, MAKE_COLOR(SCREEN_COLOR, COLOR_WHITE)); 424 426 sprintf(str, "%s: %-6d", lang_str(LANG_SOKOBAN_TEXT_MOVES), moves); … … 437 439 } 438 440 441 442 extern int module_idx; 443 void gui_module_menu_kbd_process() { 444 gui_default_kbd_process_menu_btn(); 445 module_async_unload(module_idx); 446 } 447 448 449 // ========= MODULE INIT ================= 450 #include "module_load.h" 451 int module_idx=-1; 452 453 /***************** BEGIN OF AUXILARY PART ********************* 454 ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 455 **************************************************************/ 456 457 void* MODULE_EXPORT_LIST[] = { 458 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 459 /* 1 */ (void*)0 460 }; 461 462 463 //--------------------------------------------------------- 464 // PURPOSE: Bind module symbols with chdk. 465 // Required function 466 // PARAMETERS: pointer to chdk list of export 467 // RETURN VALUE: 1 error, 0 ok 468 //--------------------------------------------------------- 469 int _module_loader( void** chdk_export_list ) 470 { 471 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 472 return 1; 473 474 // Safe bind of conf. 475 tConfigVal configVal; 476 CONF_BIND_INT(40, conf_sokoban_level ); 477 478 return 0; 479 } 480 481 482 483 //--------------------------------------------------------- 484 // PURPOSE: Finalize module operations (close allocs, etc) 485 // RETURN VALUE: 0-ok, 1-fail 486 //--------------------------------------------------------- 487 int _module_unloader() 488 { 489 return 0; 490 } 491 492 493 //--------------------------------------------------------- 494 // PURPOSE: Default action for simple modules (direct run) 495 // NOTE: Please comment this function if no default action and this library module 496 //--------------------------------------------------------- 497 int _module_run(int moduleidx, int argn, int* arguments) 498 { 499 module_idx=moduleidx; 500 501 int rv = gui_sokoban_init(); 502 if ( ! rv ) 503 module_async_unload(moduleidx); // fail to init - "unload me" 504 505 return 0; 506 } 507 508 509 /******************** Module Information structure ******************/ 510 511 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 512 sizeof(struct ModuleInfo), 513 514 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 515 ANY_PLATFORM_ALLOWED, // Specify platform dependency 516 0, // flag 517 -LANG_MENU_GAMES_SOKOBAN, // Module name 518 1, 0, // Module version 519 (int32_t)"Game" 520 }; 521 522 /*************** END OF AUXILARY PART *******************/ -
trunk/core/gui_sokoban.h
r522 r1505 5 5 extern int gui_sokoban_init(); 6 6 extern void gui_sokoban_kbd_process(); 7 extern void gui_sokoban_draw( );7 extern void gui_sokoban_draw(int enforce_redraw); 8 8 9 9 //------------------------------------------------------------------- -
trunk/core/gui_tetris.c
r1467 r1505 121 121 { 122 122 // Check if directory exists and create it if it does not. 123 struct stat st;124 if (s tat(dirname,&st) != 0) return mkdir(dirname);123 struct STD_stat st; 124 if (safe_stat(dirname,&st) != 0) return mkdir(dirname); 125 125 return 0; // Success 126 126 } … … 738 738 **************************************************************/ 739 739 740 int _chdk_required_ver = 1; // minimal required chdk build. 0-no limitation741 int _chdk_required_platfid = 0; // platform-specific module. 0-no limitation742 743 740 void* MODULE_EXPORT_LIST[] = { 744 741 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, … … 793 790 794 791 792 /******************** Module Information structure ******************/ 793 794 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 795 sizeof(struct ModuleInfo), 796 797 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 798 ANY_PLATFORM_ALLOWED, // Specify platform dependency 799 0, // flag 800 (int32_t)"Tetris", // Module name 801 1, 0, // Module version 802 (int32_t)"Game" 803 }; 804 795 805 /*************** END OF AUXILARY PART *******************/ -
trunk/core/kbd.c
r1464 r1505 12 12 #include "lang.h" 13 13 #include "gui_lang.h" 14 15 #include "module_load.h" 16 #include "gui.h" 14 17 15 18 long kbd_last_clicked; … … 171 174 unsigned int nCrzpos,i; 172 175 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 173 185 174 186 if(conf.ricoh_ca1_mode && conf.remote_enable) { -
trunk/core/luascript.c
r1479 r1505 10 10 #include "stdlib.h" 11 11 #include "raw.h" 12 #include " raw_merge.h"12 #include "modules.h" 13 13 #include "levent.h" 14 14 #include "console.h" … … 127 127 void lua_script_reset() 128 128 { 129 module_rawop_unload(); 129 130 lua_close( L ); 130 131 L = 0; … … 268 269 int value; 269 270 value=luaL_checknumber( L, 1 ); 271 if (module_curves_load()) 272 return luaL_argerror(L,1,"fail to load curves module"); 270 273 curve_set_mode(value); 271 274 return 0; … … 818 821 // the Func/Set key again will enter the Script menu, not the File Browser 819 822 kbd_reset_autoclicked_key(); 823 824 lua_pushstring( Lt, (fn && fn[0])? fn : NULL ); 825 820 826 } 821 827 … … 826 832 action_push(AS_FILE_BROWSER); 827 833 // Switch to file browser gui mode. Path can be supplied in call or defaults to "A" (root directory). 828 gui_fselect_init(LANG_STR_FILE_BROWSER, luaL_optstring( L, 1, "A" ), "A", file_browser_selected);834 module_fselect_init(LANG_STR_FILE_BROWSER, luaL_optstring( L, 1, "A" ), "A", file_browser_selected); 829 835 // Yield the script so that the action stack will process the AS_FILE_BROWSER action 830 836 return lua_yield(L, 0); … … 1381 1387 { 1382 1388 int op = luaL_checknumber(L,1); 1389 if (!module_rawop_load()) 1390 return luaL_argerror(L,1,"fail to load raw merge module"); 1383 1391 if (op == RAW_OPERATION_SUM || op == RAW_OPERATION_AVERAGE) { 1384 raw_merge_start(op);1392 librawop.raw_merge_start(op); 1385 1393 } 1386 1394 else { … … 1393 1401 static int luaCB_raw_merge_add_file( lua_State* L ) 1394 1402 { 1395 raw_merge_add_file(luaL_checkstring( L, 1 )); 1403 if (!module_rawop_load()) 1404 return luaL_argerror(L,1,"fail to load raw merge module"); 1405 librawop.raw_merge_add_file(luaL_checkstring( L, 1 )); 1396 1406 return 0; 1397 1407 } … … 1399 1409 static int luaCB_raw_merge_end( lua_State* L ) 1400 1410 { 1401 raw_merge_end(); 1411 if (!module_rawop_load()) 1412 return luaL_argerror(L,1,"fail to load raw merge module"); 1413 librawop.raw_merge_end(); 1402 1414 return 0; 1403 1415 } -
trunk/core/main.c
r1484 r1505 8 8 #include "raw.h" 9 9 #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 12 16 static int raw_need_postprocess; 13 17 static volatile int spytask_can_start; … … 142 146 mkdir("A/CHDK/LANG"); 143 147 mkdir("A/CHDK/BOOKS"); 148 mkdir("A/CHDK/MODULES"); 144 149 mkdir("A/CHDK/GRIDS"); 145 150 #ifdef OPT_CURVES … … 184 189 { 185 190 histogram_process(); 191 192 186 193 #ifdef OPT_EDGEOVERLAY 187 if(conf.edge_overlay_thresh && conf.edge_overlay_enable) edge_overlay(); 194 if(conf.edge_overlay_thresh && conf.edge_overlay_enable) { 195 196 // We need to skip first tick because stability 197 static int skip_counter=1; 198 199 if (skip_counter>0) { 200 skip_counter--; 201 } 202 else if (module_edgeovr_load()) { 203 edge_overlay(); 204 } 205 } 188 206 #endif 189 207 } … … 199 217 draw_txt_string(2, 2, osd_buf, conf.osd_color); 200 218 #endif 219 220 // Process async module unload requests 221 module_tick_unloader(); 222 201 223 msleep(20); 202 224 } -
trunk/core/module_exportlist.c
r1467 r1505 2 2 * THIS FILE IS FOR DECLARATION/LISTING OF EXPORTED TO MODULES SYMBOLS 3 3 * 4 * CHDK-FLAT Module System. Sergey Taranenko (@tsv)4 * CHDK-FLAT Module System. Sergey Taranenko aka tsvstar 5 5 */ 6 6 … … 9 9 #include "platform.h" 10 10 #include "stdlib.h" 11 #include "stdlib_unified.h" 11 12 #include "keyboard.h" 12 13 … … 14 15 #include "gui_draw.h" 15 16 #include "gui_batt.h" 17 #include "gui_menu.h" 16 18 #include "gui_osd.h" 19 #include "gui_mbox.h" 20 #include "gui_mpopup.h" 17 21 #include "conf.h" 18 #include "gui_mbox.h"19 22 #include "raw.h" 20 #include "gui_mpopup.h"21 23 #include "bitvector.h" 22 24 #include "font.h" 23 25 24 26 #include "modules.h" 27 #include "module_load.h" 25 28 #include "raw.h" 26 #include "dng.h"27 29 28 30 … … 53 55 int RAW_CHDK_ROWLEN = RAW_ROWLEN ; 54 56 57 58 char SCREEN__EXPORTEDSYM_COLOR = SCREEN_COLOR ; 59 char COLOR__EXPORTEDSYM_WHITE = COLOR_WHITE ; 60 char COLOR__EXPORTEDSYM_RED = COLOR_RED ; 61 char COLOR__EXPORTEDSYM_GREY = COLOR_GREY ; 62 char COLOR__EXPORTEDSYM_GREEN = COLOR_GREEN ; 63 char COLOR__EXPORTEDSYM_BLUE_LT = COLOR_BLUE_LT ; 64 char COLOR__EXPORTEDSYM_BLUE = COLOR_BLUE ; 65 char COLOR__EXPORTEDSYM_YELLOW = COLOR_YELLOW ; 66 char COLOR__EXPORTEDSYM_BG = COLOR_BG ; 67 char COLOR__EXPORTEDSYM_FG = COLOR_FG ; 68 char COLOR__EXPORTEDSYM_SELECTED_BG = COLOR_SELECTED_BG ; 69 char COLOR__EXPORTEDSYM_SELECTED_FG = COLOR_SELECTED_FG ; 70 char COLOR__EXPORTEDSYM_ALT_BG = COLOR_ALT_BG ; 71 char COLOR__EXPORTEDSYM_SPLASH_RED = COLOR_SPLASH_RED ; 72 char COLOR__EXPORTEDSYM_SPLASH_PINK = COLOR_SPLASH_PINK ; 73 char COLOR__EXPORTEDSYM_SPLASH_GREY = COLOR_SPLASH_GREY ; 74 char COLOR__EXPORTEDSYM_HISTO_R = COLOR_HISTO_R ; 75 char COLOR__EXPORTEDSYM_HISTO_R_PLAY = COLOR_HISTO_R_PLAY ; 76 char COLOR__EXPORTEDSYM_HISTO_B = COLOR_HISTO_B ; 77 char COLOR__EXPORTEDSYM_HISTO_G = COLOR_HISTO_G ; 78 char COLOR__EXPORTEDSYM_HISTO_G_PLAY = COLOR_HISTO_G_PLAY ; 79 char COLOR__EXPORTEDSYM_HISTO_BG = COLOR_HISTO_BG ; 80 char COLOR__EXPORTEDSYM_HISTO_RG = COLOR_HISTO_RG ; 81 char COLOR__EXPORTEDSYM_HISTO_RB = COLOR_HISTO_RB ; 82 char COLOR__EXPORTEDSYM_HISTO_RB_PLAY = COLOR_HISTO_RB_PLAY ; 83 char COLOR__EXPORTEDSYM_HISTO_B_PLAY = COLOR_HISTO_B_PLAY ; 84 char COLOR__EXPORTEDSYM_HISTO_BG_PLAY = COLOR_HISTO_BG_PLAY ; 85 char COLOR__EXPORTEDSYM_HISTO_RG_PLAY = COLOR_HISTO_RG_PLAY ; 86 87 short EDGE__EXPORTEDSYM_HMARGIN = EDGE_HMARGIN; 88 short CAM__EXPORTEDSYM_TS_BUTTON_BORDER = CAM_TS_BUTTON_BORDER; 89 90 55 91 /* EXPORTED_DEFINES_END */ 56 92 … … 58 94 // 1. DO NOT CHANGE ORDER AND DO NOT DELETE EXISTED ENTRIES 59 95 // 2. VARIABLE conf SHOULDN'T EXIST IN THE LIST TO KEEP ISOLATION. USE set|get_chdk_conf|get_chdk_conf_ptr INSTEAD 96 // STOPLIST: conf, open, opendir, closedir, rewinddir, readdir, stat 60 97 61 98 void* CHDK_EXPORT_LIST[] = { … … 71 108 umalloc, 72 109 ufree, 73 open,110 safe_open, 74 111 write, 75 112 lseek, … … 83 120 fread, 84 121 fwrite, 85 s tat,86 opendir,87 readdir,88 closedir,122 safe_stat, 123 safe_opendir, 124 safe_readdir, 125 safe_closedir, 89 126 90 127 get_tick_count, … … 144 181 // for edgeovr.flt 145 182 vid_get_viewport_width, 146 vid_get_viewport_buffer_width,183 vid_get_viewport_byte_width, 147 184 vid_get_viewport_xoffset, 148 185 vid_get_viewport_yoffset, 186 vid_get_viewport_yscale, 149 187 vid_get_viewport_fb_d, 150 188 kbd_is_key_pressed, … … 192 230 msleep, 193 231 GetTotalCardSpaceKb, 194 convert_dng_to_chdk_raw,232 module_convert_dng_to_chdk_raw, 195 233 raw_prepare_develop, 196 234 … … 209 247 mkdir, 210 248 249 gui_bind_mode, 250 251 // modlist.flt 252 load_from_file, 253 rbf_draw_string_len, 254 rbf_draw_menu_header, 255 gui_force_restore, 256 257 // modmenu.flt 258 gui_menu_run_fltmodule, 259 260 // export palette 261 &SCREEN__EXPORTEDSYM_COLOR , 262 &COLOR__EXPORTEDSYM_WHITE , 263 &COLOR__EXPORTEDSYM_RED , 264 &COLOR__EXPORTEDSYM_GREY , 265 &COLOR__EXPORTEDSYM_GREEN , 266 &COLOR__EXPORTEDSYM_BLUE_LT , 267 &COLOR__EXPORTEDSYM_BLUE , 268 &COLOR__EXPORTEDSYM_YELLOW , 269 &COLOR__EXPORTEDSYM_BG , 270 &COLOR__EXPORTEDSYM_FG , 271 &COLOR__EXPORTEDSYM_SELECTED_BG , 272 &COLOR__EXPORTEDSYM_SELECTED_FG , 273 &COLOR__EXPORTEDSYM_ALT_BG , 274 &COLOR__EXPORTEDSYM_SPLASH_RED , 275 &COLOR__EXPORTEDSYM_SPLASH_PINK , 276 &COLOR__EXPORTEDSYM_SPLASH_GREY , 277 &COLOR__EXPORTEDSYM_HISTO_R , 278 &COLOR__EXPORTEDSYM_HISTO_R_PLAY , 279 &COLOR__EXPORTEDSYM_HISTO_B , 280 &COLOR__EXPORTEDSYM_HISTO_G , 281 &COLOR__EXPORTEDSYM_HISTO_G_PLAY , 282 &COLOR__EXPORTEDSYM_HISTO_BG , 283 &COLOR__EXPORTEDSYM_HISTO_RG , 284 &COLOR__EXPORTEDSYM_HISTO_RB , 285 &COLOR__EXPORTEDSYM_HISTO_RB_PLAY, 286 &COLOR__EXPORTEDSYM_HISTO_B_PLAY , 287 &COLOR__EXPORTEDSYM_HISTO_BG_PLAY, 288 &COLOR__EXPORTEDSYM_HISTO_RG_PLAY, 289 290 // some common required sym 291 &EDGE__EXPORTEDSYM_HMARGIN, 292 &CAM__EXPORTEDSYM_TS_BUTTON_BORDER, 293 294 // profile.flt 295 find_mnu, 296 lang_strhash31, 297 211 298 0 212 299 }; 213 214 /* debug_open,215 debug_print_int,216 debug_print,217 debug_flush,218 debug_close,219 */220 -
trunk/core/module_load.c
r1467 r1505 2 2 * CHDK-FLAT Module System. 3 3 * 4 * (c)2011 Sergey Taranenko aka @tsv4 * (c)2011 Sergey Taranenko aka tsvstar 5 5 * 6 6 * This is main file of module processing system. Module load/unload/service functions … … 10 10 #include "console.h" 11 11 #include "gui.h" 12 #include "platform.h" 12 13 13 14 #include "flt.h" … … 20 21 //********************************************************/ 21 22 22 #include "module_exportlist.c" 23 23 extern void* CHDK_EXPORT_LIST[]; 24 24 25 25 #define MAX_NUM_LOADED_MODULES 10 … … 109 109 strcpy(tgt,name); 110 110 else 111 sprintf(tgt," A/CHDK/MODULES/%s",name);111 sprintf(tgt,"%s/%s",MODULES_PATH,name); 112 112 } 113 113 … … 169 169 ptr = (uint32_t*)(buf+*relocbuf); 170 170 //@tsv todo: if (*relocbuf>=flat->reloc_start) error_out_of_bound 171 // No such symbol to import 171 172 if ( *ptr<2 || *ptr>EXPORTLIST_LAST_IDX ) 172 173 return 0; 173 174 174 *ptr = /*0xFFFFFFFE &*/ (uint32_t) CHDK_EXPORT_LIST[*ptr]; 175 *ptr = (uint32_t) CHDK_EXPORT_LIST[*ptr]; 176 // Empty symbol - module could only if import such symbol manually 177 if ( *ptr==0 ) 178 return 0; 175 179 relocbuf++; 176 180 } … … 293 297 if ( flat.rev!=FLAT_VERSION || memcmp( flat.magic, FLAT_MAGIC_NUMBER, 4) ) 294 298 return moduleload_error("bad magicnum", 0); 295 296 if ( flat.chdk_min_version > CHDK_BUILD_NUM )297 return moduleload_error("require CHDK%d", flat.chdk_min_version);298 299 if ( flat.chdk_req_platfid && flat.chdk_req_platfid != PLATFORMID )300 return moduleload_error("require platfid %d", flat.chdk_req_platfid);301 299 302 300 size_flat = flat.bss_end+1; … … 313 311 b_close(-1); // filebuf not needed below 314 312 313 314 // Module info checks 315 316 struct ModuleInfo* _module_info = 0; 317 if ( flat._module_info ) 318 { 319 _module_info = (struct ModuleInfo* ) ((unsigned int)flat_buf+flat._module_info); 320 321 if ( _module_info->magicnum != MODULEINFO_V1_MAGICNUM || 322 _module_info->sizeof_struct != sizeof(struct ModuleInfo) ) 323 return moduleload_error("Malformed module info", 0 ); 324 325 if ( _module_info->chdk_required_branch && 326 _module_info->chdk_required_branch != CURRENT_CHDK_BRANCH ) 327 return moduleload_error("require different CHDK branch",0 ); 328 329 if ( _module_info->chdk_required_ver > CHDK_BUILD_NUM) 330 return moduleload_error("require CHDK%05d", _module_info->chdk_required_ver); 331 332 if ( _module_info->chdk_required_platfid && 333 _module_info->chdk_required_platfid != PLATFORMID ) 334 return moduleload_error("require platfid %d", _module_info->chdk_required_platfid); 335 } 336 337 // Make relocations 338 315 339 if ( !module_do_action( "reloc", flat.reloc_start, flat.reloc_count, module_do_relocations ) ) 316 340 return -1; … … 321 345 module_fd = -1; 322 346 347 // Module is valid. Finalize binding 348 323 349 modules[idx] = (struct flat_hdr* )flat_buf; 324 350 351 modules[idx]->_module_info = (uint32_t) _module_info; 325 352 if ( flat._module_loader ) { modules[idx]->_module_loader += (unsigned int)flat_buf; } 326 353 if ( flat._module_unloader ) { modules[idx]->_module_unloader += (unsigned int)flat_buf; } 327 354 if ( flat._module_run ) { modules[idx]->_module_run += (unsigned int)flat_buf; } 328 355 329 330 356 // store runtime params 331 357 flat_module_name_make(modules[idx]->modulename, name); 332 modules[idx]->runtime_bind_callback = callback; //@tsv reuse unneeded entry to store valuable358 modules[idx]->runtime_bind_callback = (uint32_t) callback; //@tsv reuse unneeded entry to store valuable 333 359 334 360 int bind_err=0; -
trunk/core/module_load.h
r1467 r1505 4 4 #include "gui.h" 5 5 #include "gui_draw.h" 6 #include "flt.h" 7 #ifndef THIS_IS_CHDK_CORE 8 #include "module_exportlist.h" 9 #endif 10 11 // This is main CHDK trunk 12 #define CURRENT_CHDK_BRANCH 1 13 14 #define MODULES_PATH "A/CHDK/MODULES" 15 16 17 // Base typedefs 18 //------------------- 6 19 7 20 #define EXPORTLIST_MAGIC_NUMBER 0x43215678 … … 18 31 }; 19 32 33 34 // Common module functions 35 //------------------------- 36 20 37 int module_check_is_exist(char* name); 21 38 int module_find(char * name ); … … 28 45 void module_set_flags(unsigned int idx, char value); 29 46 47 void* module_get_adr(unsigned int idx); 48 49 50 // Asynchronous unloading 51 //------------------------- 30 52 void module_async_unload(unsigned int idx); 31 53 void module_async_unload_allrunned(int enforce); 32 54 void module_tick_unloader(); 33 55 34 void* module_get_adr(unsigned int idx); 35 36 56 // In-module binding to conf. 57 //--------------------------- 37 58 #define CONF_BIND_INT(idConf,var) if ( conf_getValue(idConf, &configVal) == CONF_VALUE ) { var = configVal.pInt; } else { return 1;} 38 59 #define CONF_BIND_COLOR(idConf,var) if ( conf_getValue(idConf, &configVal) == CONF_VALUE ) { var = (color*)configVal.pInt; } else { return 1;} -
trunk/core/module_wrappers.c
r1495 r1505 16 16 { 17 17 int real_flags = flags & ~(STD_O_TRUNC|STD_O_CREAT); 18 if ( flags & STD_O_TRUNC ) real_flags = O_TRUNC;19 if ( flags & STD_O_CREAT ) real_flags = O_CREAT;18 if ( flags & STD_O_TRUNC ) real_flags |= O_TRUNC; 19 if ( flags & STD_O_CREAT ) real_flags |= O_CREAT; 20 20 return open( name, real_flags, mode); 21 21 } … … 95 95 memset( &(dir->de), 0, sizeof(dir->de)); 96 96 #else 97 dir->de.unk1 = de->unk1; 97 98 dir->de.attrib = de->attrib; 98 99 dir->de.size = de->size; -
trunk/core/modules.c
r1467 r1505 2 2 * CHDK-FLAT Module System. 3 3 * 4 * (c)2011 Sergey Taranenko aka @tsv4 * (c)2011 Sergey Taranenko aka tsvstar 5 5 * 6 6 * Specific "shortcuts", dynamic libraries binding … … 13 13 #include "conf.h" 14 14 #include "gui_draw.h" 15 #include "dng.h" 15 16 16 17 /************* DYNAMIC LIBRARY RAWOPERATION ******/ … … 242 243 } 243 244 244 245 /************* OTHER MODULES ******/ 246 247 void module_convert_dng_to_chdk_raw(char* fn) 248 { 249 #if DNG_SUPPORT 250 convert_dng_to_chdk_raw(fn); 251 #endif 252 } -
trunk/core/modules.h
r1467 r1505 38 38 39 39 40 41 //-------------------------- 42 void module_convert_dng_to_chdk_raw(char* fn); 43 44 40 45 #endif -
trunk/core/modules/Makefile
r1467 r1505 15 15 LDLIBS= -lgcc 16 16 LDOPTS=-nostdlib -Wl,--allow-shlib-undefined -Wl,-T,$(topdir)tools/link-boot.ld 17 LDOPTS+=-Wl,-N,-Ttext, $(MEMISOSTART) -r-d17 LDOPTS+=-Wl,-N,-Ttext,0x0016ee30 -r -Wl,-d 18 18 19 19 OBJS=../gui_calendar.o ../gui_bench.o ../gui_4wins.o ../gui_mastermind.o ../gui_reversi.o \ 20 ../gui_sokoban.o ../gui_read.o ../edgeoverlay.o ../gui_debug.o ../gui_palette.o \ 21 ../curves.o ../gui_fselect.o ../nothumb.o ../gui_mpopup.o ../gui_tetris.o ../gui_snake.o 20 ../gui_sokoban.o ../gui_read.o ../gui_debug.o ../gui_tetris.o ../gui_snake.o 21 22 23 CFLAGS+=-DOPT_GENERIC_MODULES 24 OPT_OBJS= ../gui_fselect.o ../nothumb.o ../gui_mpopup.o ../curves.o ../edgeoverlay.o ../gui_palette.o 25 OPT_FLT= fselect.flt edgeovr.flt curves.flt mpopup.flt palette.flt 22 26 23 27 24 28 all: exportlist ../flt.h \ 25 29 benchm.flt calend.flt 4wins.flt mastmind.flt reversi.flt sokoban.flt _rawop10.flt _rawop12.flt \ 26 edgeovr.flt txtread.flt memview.flt palette.flt modinsp.flt curves.flt fselect.flt mpopup.flt \ 27 tetris.flt snake.flt 30 txtread.flt memview.flt modinsp.flt tetris.flt snake.flt modmenu.flt $(OPT_FLT) 28 31 29 32 %.o: %.c … … 44 47 calend.elf: simple_module.o ../gui_calendar.o 45 48 @echo \-\> $@ 46 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)49 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 47 50 48 51 benchm.elf: simple_module.o ../gui_bench.o 49 52 @echo \-\> $@ 50 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)53 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 51 54 52 4wins.elf: simple_ module.o ../gui_4wins.o55 4wins.elf: simple_game.o ../gui_4wins.o 53 56 @echo \-\> $@ 54 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)57 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 55 58 56 mastmind.elf: simple_ module.o ../gui_mastermind.o59 mastmind.elf: simple_game.o ../gui_mastermind.o 57 60 @echo \-\> $@ 58 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)61 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 59 62 60 reversi.elf: simple_ module.o ../gui_reversi.o63 reversi.elf: simple_game.o ../gui_reversi.o 61 64 @echo \-\> $@ 62 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)65 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 63 66 64 67 tetris.elf: ../gui_tetris.o 65 68 @echo \-\> $@ 66 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)69 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 67 70 68 71 snake.elf: ../gui_snake.o 69 72 @echo \-\> $@ 70 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)73 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 71 74 72 75 sokoban.elf: ../gui_sokoban.o 73 76 @echo \-\> $@ 74 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)77 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 75 78 76 79 memview.elf: ../gui_debug.o 77 80 @echo \-\> $@ 78 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)81 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 79 82 80 83 palette.elf: ../gui_palette.o 81 84 @echo \-\> $@ 82 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)85 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 83 86 84 87 mpopup.elf: ../gui_mpopup.o 85 88 @echo \-\> $@ 86 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)89 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 87 90 88 91 txtread.elf: ../gui_read.o 89 92 @echo \-\> $@ 90 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)93 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 91 94 92 95 edgeovr.elf: ../edgeoverlay.o $(OBJ_ISDIGIT) 93 96 @echo \-\> $@ 94 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)97 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 95 98 96 99 curves.elf: ../curves.o 97 100 @echo \-\> $@ 98 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)101 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 99 102 100 103 modinsp.elf: module_inspector.o 101 104 @echo \-\> $@ 102 $(CC) $(CFLAGS) -o $@ --start-group $^ $(LDLIBS) --end-group $(LDFLAGS) $(LDOPTS) 105 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 106 107 modmenu.elf: module_menu.o ../nothumb.o 108 @echo \-\> $@ 109 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 103 110 104 111 _rawop10.elf: raw_merge10.o 105 112 @echo \-\> $@ 106 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)113 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 107 114 108 115 _rawop12.elf: raw_merge12.o 109 116 @echo \-\> $@ 110 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)117 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 111 118 112 119 raw_merge10.o: ../raw_merge.c … … 120 127 #lua.elf: lib_edgeoverlay.o ../luascript.o $(topdir)lib/lua/liblua.a 121 128 # @echo \-\> $@ 122 # $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)129 # $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 123 130 124 131 fselect.elf: ../gui_fselect.o ../nothumb.o 125 132 @echo \-\> $@ 126 $(CC) $(CFLAGS) -o $@ - -start-group $^ $(LDLIBS)--end-group $(LDFLAGS) $(LDOPTS)133 $(CC) $(CFLAGS) -o $@ -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group $(LDFLAGS) $(LDOPTS) 127 134 128 135 ../nothumb.o: ../nothumb.c … … 131 138 132 139 clean: 133 rm -f *.o *.elf.syms *.elf $(OBJS)140 rm -f *.o *.elf.syms *.elf *.flt $(OBJS) $(OPT_OBJS) 134 141 135 142 distclean: clean -
trunk/core/modules/module_inspector.c
r1467 r1505 9 9 10 10 extern int basic_module_init(); 11 void * _getmeminfo=0;11 void (*_getmeminfo)(void*) = 0; 12 12 13 13 /***************** BEGIN OF AUXILARY PART ********************* 14 14 ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 15 15 **************************************************************/ 16 17 int _chdk_required_ver = 0; // minimal required chdk build. 0-no limitation18 int _chdk_required_platfid = 0; // platform-specific module. 0-no limitation19 16 20 17 void* MODULE_EXPORT_LIST[] = { … … 63 60 return 0; 64 61 } 62 63 /******************** Module Information structure ******************/ 64 65 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 66 sizeof(struct ModuleInfo), 67 68 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 69 ANY_PLATFORM_ALLOWED, // Specify platform dependency 70 0, // flag 71 (int32_t)"Module Inspector",// Module name 72 1, 0, // Module version 73 (int32_t)"Show list of loaded modules" 74 }; 65 75 66 76 … … 165 175 if (_getmeminfo) { 166 176 167 extern void GetMemInfo(cam_meminfo*);168 169 177 cam_meminfo meminfo; 170 178 memset(&meminfo,sizeof(meminfo),0); 171 GetMemInfo(&meminfo);179 _getmeminfo(&meminfo); 172 180 173 181 char txt[50]; -
trunk/core/modules/module_menu.c
r1489 r1505 122 122 CMenu* scan_directory(const char* dir) { 123 123 124 DIR *d;125 struct dirent *de;126 static struct stat st;124 STD_DIR *d; 125 struct STD_dirent *de; 126 static struct STD_stat st; 127 127 128 128 char curdir[100]; … … 139 139 for ( iter=1; iter<=2; iter++ ) 140 140 { 141 d = opendir(curdir);141 d = safe_opendir(curdir); 142 142 if (!d) return 0; 143 143 144 144 count = 0; 145 for( de = readdir(d); de; de =readdir(d) ) {145 for( de = safe_readdir(d); de; de = safe_readdir(d) ) { 146 146 147 147 if (de->d_name[0] == 0xE5 /* deleted entry */ ) … … 155 155 156 156 sprintf(buf, "%s/%s", curdir, de->d_name); 157 if (s tat(buf, &st)!=0)157 if (safe_stat(buf, &st)!=0) 158 158 continue; 159 159 … … 213 213 } 214 214 215 closedir(d);215 safe_closedir(d); 216 216 217 217 // Iteration#1 final: allocate menuitems 218 218 if (iter==1) { 219 219 220 if ( count==0 ) { closedir(d); return 0;}220 if ( count==0 ) { safe_closedir(d); return 0;} 221 221 222 222 len = sizeof(CMenu) + sizeof(CMenuItem)*(count+2); -
trunk/core/modules/simple_module.c
r1467 r1505 12 12 ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 13 13 **************************************************************/ 14 15 int _chdk_required_ver = 1; // minimal required chdk build. 0-no limitation16 int _chdk_required_platfid = 0; // platform-specific module. 0-no limitation17 14 18 15 void* MODULE_EXPORT_LIST[] = { -
trunk/core/raw.c
r1497 r1505 6 6 #include "dng.h" 7 7 #ifdef OPT_CURVES 8 #include " curves.h"8 #include "modules.h" 9 9 #endif 10 10 #include "shot_histogram.h" … … 75 75 } 76 76 #ifdef OPT_CURVES 77 if (conf.curve_enable) curve_apply(); 77 if (conf.curve_enable) { 78 if (module_curves_load()) 79 curve_apply(); 80 } 78 81 #endif 79 82 finished(); … … 181 184 182 185 #ifdef OPT_CURVES 183 if (conf.curve_enable) curve_apply(); 186 if (conf.curve_enable) { 187 if (module_curves_load()) 188 curve_apply(); 189 } 184 190 #endif 185 191 return ret; -
trunk/core/raw_merge.c
r1211 r1505 8 8 #include "lang.h" 9 9 #include "conf.h" 10 #include "module_exportlist.h" 11 10 12 #define TEMP_FILE_NAME "A/raw16.tmp" 11 13 #define TEMP_FILE_NAME_1 "A/raw16_1.tmp" … … 35 37 int result; 36 38 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; 40 42 return result; 41 43 … … 54 56 static struct utimbuf t; 55 57 56 struct stat st;57 58 if (s tat((char *)from,&st) != 0 || st.st_size!=hook_raw_size())58 struct STD_stat st; 59 60 if (safe_stat((char *)from,&st) != 0 || st.st_size!=hook_raw_size()) 59 61 return 0; 60 62 61 if (s tat((char *)sub,&st) != 0 || st.st_size!=hook_raw_size())63 if (safe_stat((char *)sub,&st) != 0 || st.st_size!=hook_raw_size()) 62 64 return 0; 63 65 64 if( (baccum=malloc(RAW_ ROWLEN)) &&65 (bsub=malloc(RAW_ ROWLEN)) &&66 if( (baccum=malloc(RAW_CHDK_ROWLEN)) && 67 (bsub=malloc(RAW_CHDK_ROWLEN)) && 66 68 (ffrom=fopen(from, "rb")) && 67 69 (fsub=fopen(sub, "rb")) && … … 70 72 { 71 73 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==1077 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) { 79 81 s =((0x3fc&(((unsigned short)bsub[i+1])<<2)) | (bsub[i+0] >> 6)); 80 82 d =((0x3fc&(((unsigned short)baccum[i+1])<<2)) | (baccum[i+0] >> 6)); … … 129 131 } 130 132 131 #elif CAM_ SENSOR_BITS_PER_PIXEL==12132 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) { 134 136 135 137 s=((0xFF0&(((unsigned short)bsub[i+1])<<4)) | (bsub[i+0] >> 4)); … … 162 164 #endif 163 165 164 fwrite(baccum,1,RAW_ ROWLEN,fdest);166 fwrite(baccum,1,RAW_CHDK_ROWLEN,fdest); 165 167 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); 167 169 } 168 170 } … … 187 189 int raw_merge_start(int action){ 188 190 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; 190 192 avail=GetFreeCardSpaceKb()>>10; 191 193 if (avail<req) { … … 196 198 raw_action=action; 197 199 raw_count=0; 198 row=malloc(CAM_ RAW_ROWPIX*sizeof(unsigned short));200 row=malloc(CAM_CHDK_RAW_ROWPIX*sizeof(unsigned short)); 199 201 if (!row) 200 202 return 0; 201 rawrow=malloc(RAW_ ROWLEN);203 rawrow=malloc(RAW_CHDK_ROWLEN); 202 204 if (!rawrow) { 203 205 free(row); … … 210 212 int t,src,i,j,nrow; 211 213 FILE *fbrawin=NULL,*fbrawout,*fcraw; 212 struct stat st;214 struct STD_stat st; 213 215 214 216 if (!filename) 215 217 return; 216 218 217 s tat(filename,&st);219 safe_stat(filename,&st); 218 220 if (st.st_size!=hook_raw_size()) 219 221 return; … … 228 230 fbrawout=fopen(TEMP_FILE_NAME_1,"w+b"); 229 231 if (fbrawout){ 230 fread(rawrow, 1, RAW_ ROWLEN, fcraw);232 fread(rawrow, 1, RAW_CHDK_ROWLEN, fcraw); 231 233 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); 233 235 else 234 for (i=0;i<CAM_ RAW_ROWPIX;i++)236 for (i=0;i<CAM_CHDK_RAW_ROWPIX;i++) 235 237 row[i]=0; 236 238 237 for (nrow=0,j=0;nrow<CAM_ RAW_ROWS;nrow++,j++){238 239 #if CAM_ SENSOR_BITS_PER_PIXEL==10240 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){ 242 244 row[i+0]+=((0x3fc&(((unsigned short)rawrow[src+1])<<2)) | (rawrow[src+0] >> 6)); 243 245 row[i+1]+=((0x3f0&(((unsigned short)rawrow[src+0])<<4)) | (rawrow[src+3] >> 4)); … … 250 252 } 251 253 252 #elif CAM_ SENSOR_BITS_PER_PIXEL==12253 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){ 255 257 row[i+0]+=((0xFF0&(((unsigned short)rawrow[src+1])<<4)) | (rawrow[src+0] >> 4)); 256 258 row[i+1]+=((0xF00&(((unsigned short)rawrow[src+0])<<8)) | (rawrow[src+3] )); … … 263 265 #endif 264 266 265 fwrite(row, 1, CAM_ RAW_ROWPIX*sizeof(unsigned short), fbrawout);267 fwrite(row, 1, CAM_CHDK_RAW_ROWPIX*sizeof(unsigned short), fbrawout); 266 268 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); 268 270 else 269 for (i=0;i<CAM_ RAW_ROWPIX;i++)271 for (i=0;i<CAM_CHDK_RAW_ROWPIX;i++) 270 272 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); 275 277 } 276 278 } … … 307 309 fcraw=fopen(namebuf,"w+b"); 308 310 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++) { 312 314 if (raw_action==RAW_OPERATION_AVERAGE) 313 315 row[i]/=raw_count; 314 316 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); 317 319 else 318 320 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; 321 323 } 322 324 } 323 #if CAM_ SENSOR_BITS_PER_PIXEL==10324 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) { 325 327 rawrow[src+0]=(row[i+0]<<6)|(row[i+1]>>4); 326 328 rawrow[src+1]=(row[i+0]>>2); … … 334 336 rawrow[src+9]=(row[i+6]<<2)|(row[i+7]>>8); 335 337 } 336 #elif CAM_ SENSOR_BITS_PER_PIXEL==12337 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){ 338 340 rawrow[src+0]=(row[i+0]<<4)|(row[i+1]>>8); 339 341 rawrow[src+1]=(row[i+0]>>4); … … 347 349 #endif 348 350 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); 354 356 } 355 357 } … … 368 370 } 369 371 372 373 // ========= MODULE INIT ================= 374 #include "module_load.h" 375 int module_idx=-1; 376 377 /***************** BEGIN OF AUXILARY PART ********************* 378 ATTENTION: DO NOT REMOVE OR CHANGE SIGNATURES IN THIS SECTION 379 **************************************************************/ 380 381 void* MODULE_EXPORT_LIST[] = { 382 /* 0 */ (void*)EXPORTLIST_MAGIC_NUMBER, 383 /* 1 */ (void*)6, 384 385 raw_merge_start, 386 raw_merge_add_file, 387 raw_merge_end, 388 raw_subtract 389 }; 390 391 392 //--------------------------------------------------------- 393 // PURPOSE: Bind module symbols with chdk. 394 // Required function 395 // PARAMETERS: pointer to chdk list of export 396 // RETURN VALUE: 1 error, 0 ok 397 //--------------------------------------------------------- 398 int _module_loader( void** chdk_export_list ) 399 { 400 if ( (unsigned int)chdk_export_list[0] != EXPORTLIST_MAGIC_NUMBER ) 401 return 1; 402 403 return 0; 404 } 405 406 407 408 //--------------------------------------------------------- 409 // PURPOSE: Finalize module operations (close allocs, etc) 410 // RETURN VALUE: 0-ok, 1-fail 411 //--------------------------------------------------------- 412 int _module_unloader() 413 { 414 return 0; 415 } 416 417 418 /******************** Module Information structure ******************/ 419 420 struct ModuleInfo _module_info = { MODULEINFO_V1_MAGICNUM, 421 sizeof(struct ModuleInfo), 422 423 ANY_CHDK_BRANCH, 0, // Requirements of CHDK version 424 ANY_PLATFORM_ALLOWED, // Specify platform dependency 425 MODULEINFO_FLAG_SYSTEM, // flag 426 #if CAM_MODULE_SENSOR_BITS_PER_PIXEL==10 427 (int32_t)"RAW operations-10bpp(dll)",// Module name 428 #else 429 (int32_t)"RAW operations-12bpp(dll)",// Module name 430 #endif 431 1, 0, // Module version 432 #if CAM_MODULE_SENSOR_BITS_PER_PIXEL==10 433 (int32_t)"Implementation of RAW operations\n(Avg, Sum, Sub) for 10bit sensor" 434 #else 435 (int32_t)"Implementation of RAW operations\n(Avg, Sum, Sub) for 12bit sensor" 436 #endif 437 }; 438 439 440 /*************** END OF AUXILARY PART *******************/ -
trunk/core/raw_merge.h
r594 r1505 5 5 #define RAW_OPERATION_AVERAGE 1 6 6 7 8 struct 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 7 24 int raw_merge_start(int action); 8 25 void raw_merge_add_file(const char * filename); … … 10 27 int raw_subtract(const char *from, const char *sub, const char *dest); 11 28 #endif 29 30 #endif -
trunk/core/script.c
r1437 r1505 593 593 extern char* gui_fselect_result(); 594 594 // Send file name back to script caller 595 lua_pushstring( Lt, gui_fselect_result() );595 //// lua_pushstring( Lt, gui_fselect_result() ); 596 596 } 597 597 #endif -
trunk/include/gui.h
r1338 r1505 8 8 9 9 // Don't delete or re-order entries unless guiHandlers (gui.c) table is updated to match 10 enum Gui_Mode {10 enum Gui_Mode_ { 11 11 GUI_MODE_NONE = 0, 12 12 GUI_MODE_ALT, … … 14 14 GUI_MODE_PALETTE, 15 15 GUI_MODE_MBOX, 16 GUI_MODE_REVERSI,17 GUI_MODE_SOKOBAN,18 GUI_MODE_DEBUG,19 16 GUI_MODE_FSELECT, 20 GUI_MODE_READ,21 17 GUI_MODE_OSD, 22 GUI_MODE_CALENDAR,23 GUI_MODE_BENCH,24 18 GUI_MODE_MPOPUP, 25 GUI_MODE_4WINS, 26 GUI_MODE_MASTERMIND 19 GUI_MODE_COUNT 27 20 }; 21 22 23 typedef unsigned int gui_mode_t; 24 25 #define GUI_MODE_MAGICNUM 0xd36c1559 26 27 // Specific behaviour of gui mode 28 #define GUI_MODE_FLAG_NODRAWRESTORE 1 29 #define GUI_MODE_FLAG_NORESTORE_ON_SWITCH 2 30 // Binded to module gui mode 31 #define GUI_MODE_FLAG_ALIAS 4 32 33 34 // Values (bit-flag) for gui_draw argument 35 #define GUI_REDRAWFLAG_ERASEGUARD 1 36 #define GUI_REDRAWFLAG_MODE_WAS_CHANGED 2 37 #define GUI_REDRAWFLAG_DRAW_RESTORED 4 38 39 // Structure to store gui redraw and kbd process handlers for each mode 40 typedef struct 41 { 42 // Called to redraw screen. Argument is GUI_REDRAWFLAG_* set 43 void (*redraw)(int); 44 45 // Main button handler for mode 46 // Note: this pointer reused as gui_handler* for 47 // GUI_MODE_FLAG_ALIAS entries 48 // Do not use union because warning on initializer 49 void (*kbd_process)(void); 50 51 // Menu button handler for mode 52 void (*kbd_process_menu_btn)(void); 53 54 int flags; 55 56 // Safety check for modules 57 unsigned int magicnum; 58 } gui_handler; 59 60 61 62 void gui_default_kbd_process_menu_btn(); 28 63 29 64 extern void gui_redraw(); … … 32 67 extern void draw_pixel(coord x, coord y, color cl); 33 68 34 extern enum Gui_Mode gui_get_mode(); 35 extern void gui_set_mode(enum Gui_Mode mode); 69 extern gui_mode_t gui_get_mode(); 70 extern void gui_set_mode(gui_mode_t mode); 71 72 extern int gui_bind_mode(int core_mode, gui_handler* handler); 73 74 36 75 37 76 #ifdef OPT_SCRIPTING … … 39 78 #endif 40 79 80 extern void gui_menu_run_fltmodule(int arg); 81 41 82 #endif -
trunk/include/lang.h
r1393 r1505 5 5 extern void lang_init(int num); 6 6 7 extern void lang_parse_from_mem(char *buf);8 7 extern void lang_load_from_file(const char *filename); <9 8 extern void lang_map_preparsed_from_mem( char* gui_lang_default, int num );