source: trunk/core/gui.c @ 656

Revision 656, 121.9 KB checked in by reyalp, 4 years ago (diff)
  • Property svn:eol-style set to native
Line 
1#include "stdlib.h"
2#include "platform.h"
3#include "core.h"
4#include "keyboard.h"
5#include "conf.h"
6#include "camera.h"
7#include "ubasic.h"
8#include "font.h"
9#include "lang.h"
10#include "gui.h"
11#include "gui_lang.h"
12#include "gui_draw.h"
13#include "gui_menu.h"
14#include "gui_palette.h"
15#include "gui_mbox.h"
16#include "gui_mpopup.h"
17#include "gui_reversi.h"
18#include "gui_sokoban.h"
19#include "gui_4wins.h"
20#include "gui_mastermind.h"
21#ifdef OPT_DEBUGGING
22#include "gui_debug.h"
23#endif
24#include "gui_fselect.h"
25#include "gui_batt.h"
26#include "gui_space.h"
27#include "gui_osd.h"
28#ifdef OPT_TEXTREADER
29        #include "gui_read.h"
30#endif
31#ifdef OPT_CALENDAR
32        #include "gui_calendar.h"
33#endif
34#ifdef OPT_DEBUGGING
35#include "gui_bench.h"
36#endif
37#include "gui_grid.h"
38#include "histogram.h"
39#include "script.h"
40#include "motion_detector.h"
41#include "raw.h"
42#ifdef OPT_CURVES
43        #include "curves.h"
44#endif
45#include "edgeoverlay.h"
46//-------------------------------------------------------------------
47
48#define OPTIONS_AUTOSAVE
49#define SPLASH_TIME               20
50
51int script_params_has_changed=0;
52//shortcuts
53//------------------------------------------------------------------
54// #define KEY_NONE (KEY_DUMMY+1)
55
56#if !CAM_HAS_ERASE_BUTTON
57//Alt mode
58 #define SHORTCUT_TOGGLE_RAW          KEY_DISPLAY
59 #define SHORTCUT_MF_TOGGLE           KEY_UP
60//Half press shoot button   
61 #define SHORTCUT_TOGGLE_HISTO        KEY_DOWN
62 #define SHORTCUT_TOGGLE_ZEBRA        KEY_MENU
63 #define SHORTCUT_TOGGLE_OSD          KEY_RIGHT
64 #define SHORTCUT_DISABLE_OVERRIDES KEY_LEFT
65//Alt mode & Manual mode   
66 #define SHORTCUT_SET_INFINITY        KEY_DISPLAY
67 #define SHORTCUT_SET_HYPERFOCAL      KEY_DOWN
68 // For models without ZOOM_LEVER  (#if !CAM_HAS_ZOOM_LEVER)
69 // SHORTCUT_SET_INFINITY is not used
70 // KEY_DISPLAY is used for gui_subj_dist_override_koef_enum;
71 // KEY_LEFT/KEY_RIGHT is used for gui_subj_dist_override_value_enum (because of no separate ZOOM_IN/OUT)
72 
73#elif defined(CAMERA_g7) 
74//Alt mode
75 #define SHORTCUT_TOGGLE_RAW          KEY_ERASE
76//Half press shoot button   
77 #define SHORTCUT_TOGGLE_HISTO        KEY_DOWN
78 #define SHORTCUT_TOGGLE_ZEBRA        KEY_LEFT
79 #define SHORTCUT_TOGGLE_OSD          KEY_RIGHT
80 #define SHORTCUT_DISABLE_OVERRIDES KEY_UP
81//Alt mode & Manual mode 
82 #define SHORTCUT_SET_INFINITY        KEY_UP
83 #define SHORTCUT_SET_HYPERFOCAL      KEY_DOWN
84
85#elif defined(CAMERA_sx100is)
86//Alt mode
87 #define SHORTCUT_TOGGLE_RAW          KEY_ERASE
88//Half press shoot button   
89 #define SHORTCUT_TOGGLE_HISTO        KEY_UP
90 #define SHORTCUT_TOGGLE_ZEBRA        KEY_DOWN
91 #define SHORTCUT_TOGGLE_OSD          KEY_RIGHT
92 #define SHORTCUT_DISABLE_OVERRIDES KEY_LEFT
93//Alt mode & Manual mode 
94 #define SHORTCUT_SET_INFINITY        KEY_UP
95 #define SHORTCUT_SET_HYPERFOCAL      KEY_DOWN
96
97
98#else
99
100//Alt mode
101 #define SHORTCUT_TOGGLE_RAW          KEY_ERASE
102//Half press shoot button   
103 #define SHORTCUT_TOGGLE_HISTO        KEY_UP
104 #define SHORTCUT_TOGGLE_ZEBRA        KEY_LEFT
105 #define SHORTCUT_TOGGLE_OSD          KEY_RIGHT
106 #define SHORTCUT_DISABLE_OVERRIDES KEY_DOWN
107//Alt mode & Manual mode 
108 #define SHORTCUT_SET_INFINITY        KEY_UP
109 #define SHORTCUT_SET_HYPERFOCAL      KEY_DOWN
110#endif
111
112
113// forward declarations
114//-------------------------------------------------------------------
115extern void dump_memory();
116
117static void gui_draw_osd();
118
119static void gui_draw_splash(char* logo, int logo_size);
120
121void user_menu_save();
122void user_menu_restore();
123// Menu procs
124//-------------------------------------------------------------------
125static void gui_show_build_info(int arg);
126static void gui_show_memory_info(int arg);
127static void gui_draw_palette(int arg);
128static void gui_draw_reversi(int arg);
129static void gui_draw_sokoban(int arg);
130static void gui_draw_4wins(int arg);
131static void gui_draw_mastermind(int arg);
132#ifdef OPT_DEBUGGING
133        static void gui_draw_debug(int arg);
134        static void gui_draw_bench(int arg);
135#endif
136static void gui_draw_fselect(int arg);
137static void gui_draw_osd_le(int arg);
138static void gui_load_script(int arg);
139static void gui_load_script_default(int arg);
140#ifdef OPT_TEXTREADER
141static void gui_draw_read(int arg);
142static void gui_draw_read_last(int arg);
143#endif
144static void gui_draw_load_menu_rbf(int arg);
145static void gui_draw_load_symbol_rbf(int arg);          //AKA
146#ifdef OPT_TEXTREADER
147        static void gui_draw_load_rbf(int arg);
148#endif
149#ifdef OPT_CALENDAR
150static void gui_draw_calendar(int arg);
151#endif
152static void gui_draw_load_lang(int arg);
153static void gui_menuproc_mkbootdisk(int arg);
154static void gui_menuproc_edge_save(int arg);
155static void gui_menuproc_edge_load(int arg);
156static void gui_menuproc_edge_free(int arg);
157#ifdef OPT_DEBUGGING
158void gui_compare_props(int arg);
159#endif
160#ifndef OPTIONS_AUTOSAVE
161static void gui_menuproc_save(int arg);
162#endif
163static void gui_menuproc_reset(int arg);
164static void gui_grid_lines_load(int arg);
165static void gui_raw_develop(int arg);
166#ifdef OPT_DEBUGGING
167static void gui_menuproc_break_card(int arg);
168#endif
169static void gui_menuproc_swap_patitons(int arg);
170#ifdef OPT_CURVES
171        static void gui_load_curve_selected(const char *fn);
172        static void gui_load_curve(int arg);
173#endif
174static const char* gui_histo_show_enum(int change, int arg);
175static const char* gui_histo_mode_enum(int change, int arg);
176static const char* gui_temp_mode_enum(int change, int arg);
177static const char* gui_histo_layout_enum(int change, int arg);
178static const char* gui_zebra_mode_enum(int change, int arg);
179static const char* gui_zebra_draw_osd_enum(int change, int arg);
180static const char* gui_font_enum(int change, int arg);
181static const char* gui_raw_prefix_enum(int change, int arg);
182static const char* gui_raw_ext_enum(int change, int arg);
183static const char* gui_sub_batch_prefix_enum(int change, int arg);
184static const char* gui_sub_batch_ext_enum(int change, int arg);
185
186static const char* gui_raw_nr_enum(int change, int arg);
187static const char* gui_autoiso_shutter_enum(int change, int arg);
188#ifdef OPT_TEXTREADER
189        static const char* gui_reader_codepage_enum(int change, int arg);
190#endif
191static const char* gui_zoom_value_enum(int change, int arg);
192static const char* gui_show_values_enum(int change, int arg);
193static const char* gui_dof_show_value_enum(int change, int arg);
194#if CAM_ADJUSTABLE_ALT_BUTTON
195static const char* gui_alt_mode_button_enum(int change, int arg);
196#endif
197static const char* gui_alt_power_enum(int change, int arg);
198static const char* gui_video_mode_enum(int change, int arg);
199static const char* gui_fast_ev_step(int change, int arg);
200static const char* gui_video_bitrate_enum(int change, int arg);
201static const char* gui_tv_bracket_values_enum(int change, int arg);
202static const char* gui_av_bracket_values_enum(int change, int arg);
203static const char* gui_iso_bracket_koef_enum(int change, int arg);
204static const char* gui_subj_dist_bracket_koef_enum(int change, int arg);
205static const char* gui_bracket_type_enum(int change, int arg);
206static const char* gui_av_override_enum(int change, int arg);
207#if ZOOM_OVERRIDE
208static const char* gui_zoom_override_enum(int change, int arg);
209#endif
210static const char* gui_iso_override_koef_enum(int change, int arg);
211static const char* gui_tv_override_koef_enum(int change, int arg);
212static const char* gui_tv_override_value_enum(int change, int arg);
213static const char* gui_tv_enum_type_enum(int change, int arg);
214static const char* gui_subj_dist_override_value_enum(int change, int arg);
215static const char* gui_subj_dist_override_koef_enum(int change, int arg);
216/*
217static const char* gui_tv_exposure_order_enum(int change, int arg);
218static const char* gui_av_exposure_order_enum(int change, int arg);
219static const char* gui_iso_exposure_order_enum(int change, int arg);
220*/
221static const char* gui_nd_filter_state_enum(int change, int arg);
222//static const char* gui_tv_enum(int change, int arg);
223const char* gui_user_menu_show_enum(int change, int arg);
224static const char* gui_hide_osd_enum(int change, int arg);
225static const char* gui_show_clock_enum(int change, int arg);
226static const char* gui_clock_format_enum(int change, int arg);
227static const char* gui_clock_indicator_enum(int change, int arg);
228static const char* gui_clock_halfpress_enum(int change, int arg);
229static const char* gui_space_bar_enum(int change, int arg);
230static const char* gui_space_bar_size_enum(int change, int arg);
231static const char* gui_space_bar_width_enum(int change, int arg);
232static const char* gui_space_warn_type_enum(int change, int arg);
233static const char* gui_bad_pixel_enum(int change, int arg);
234static const char* gui_video_af_key_enum(int change, int arg);
235static const char* gui_show_movie_time(int change, int arg);
236static const char* gui_script_autostart_enum(int change, int arg);
237static const char* gui_script_param_set_enum(int change, int arg);
238static const char* gui_override_disable_enum(int change, int arg);
239#ifdef OPT_CURVES
240        static const char* gui_conf_curve_enum(int change, int arg);
241#endif
242#ifdef OPT_DEBUGGING
243        static const char* gui_debug_shortcut_enum(int change, int arg);
244        static const char* gui_debug_display_enum(int change, int arg);
245        static void gui_debug_shortcut(void);
246#endif
247void rinit();
248
249
250// Menu callbacks
251//-------------------------------------------------------------------
252static void cb_step_25();
253static void cb_perc();
254static void cb_volts();
255static void cb_space_perc();
256static void cb_space_mb();
257static void cb_battery_menu_change(unsigned int item);
258static void cb_zebra_restore_screen();
259static void cb_zebra_restore_osd();
260#if DNG_SUPPORT
261static void cb_change_dng();
262#endif
263#if defined (DNG_EXT_FROM) && defined(DNG_EXT_TO)
264static void cb_change_dng_usb_ext();
265#endif
266
267// for memory info, duplicated from lowlevel
268extern const char _start,_end;
269
270#ifdef OPT_DEBUGGING
271static int debug_tasklist_start;
272static int debug_display_direction=1;
273#endif
274// Menu definition
275//-------------------------------------------------------------------
276static CMenuItem remote_submenu_items[] = {
277    {0x71,LANG_MENU_REMOTE_ENABLE,            MENUITEM_BOOL,                    &conf.remote_enable},
278    {0x0,LANG_MENU_SYNCHABLE_REMOTE,          MENUITEM_SEPARATOR },
279        {0x71,LANG_MENU_SYNCHABLE_REMOTE_ENABLE,  MENUITEM_BOOL,                    &conf.ricoh_ca1_mode            },   
280    {0x5c,LANG_MENU_SYNCH_ENABLE,             MENUITEM_BOOL,                    &conf.synch_enable              },   
281    {0x5c,LANG_MENU_SYNCH_DELAY_ENABLE,       MENUITEM_BOOL,                    &conf.synch_delay_enable        },   
282    {0x5c,LANG_MENU_SYNCH_DELAY_VALUE,        MENUITEM_INT|MENUITEM_F_UNSIGNED, &conf.synch_delay_value         },   
283    {0x5c,LANG_MENU_SYNCH_DELAY_COARSE_VALUE, MENUITEM_INT|MENUITEM_F_UNSIGNED, &conf.synch_delay_coarse_value  },   
284    {0x5c,LANG_MENU_REMOTE_ZOOM_ENABLE,       MENUITEM_BOOL,                    &conf.remote_zoom_enable        },
285    {0x5f,LANG_MENU_REMOTE_ZOOM_TIMEOUT,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.zoom_timeout, MENU_MINMAX(2,10)},
286    {0x51,LANG_MENU_BACK,                     MENUITEM_UP },
287    {0}
288};
289static CMenu remote_submenu = {0x86,LANG_MENU_REMOTE_PARAM_TITLE, NULL, remote_submenu_items };
290
291static CMenuItem script_submenu_items_top[] = {
292    {0x35,LANG_MENU_SCRIPT_LOAD,             MENUITEM_PROC,                      (int*)gui_load_script },
293    {0x5f,LANG_MENU_SCRIPT_DELAY,            MENUITEM_INT|MENUITEM_F_UNSIGNED,   &conf.script_shoot_delay },
294        // remote autostart
295        {0x5f,LANG_MENU_SCRIPT_AUTOSTART,               MENUITEM_ENUM,                                          (int*)gui_script_autostart_enum },
296
297#if CAM_REMOTE
298    {0x86,LANG_MENU_REMOTE_PARAM,            MENUITEM_SUBMENU,   (int*)&remote_submenu },
299        //{0x71,LANG_MENU_SCRIPT_REMOTE_ENABLE, MENUITEM_BOOL,                                          &conf.remote_enable},
300#endif
301    {0x5d,LANG_MENU_SCRIPT_DEFAULT_VAL,     MENUITEM_PROC,                      (int*)gui_load_script_default },
302    {0x5e,LANG_MENU_SCRIPT_PARAM_SET,     MENUITEM_ENUM,                         (int*)gui_script_param_set_enum },
303    {0x5c,LANG_MENU_SCRIPT_PARAM_SAVE,             MENUITEM_BOOL,                    &conf.script_param_save              },   
304    {0x0,(int)script_title,                 MENUITEM_SEPARATOR },
305//    {0x0,LANG_MENU_SCRIPT_CURRENT,          MENUITEM_SEPARATOR },
306//    {0x0,(int)script_title,                 MENUITEM_TEXT },
307//    {0x0,LANG_MENU_SCRIPT_PARAMS,           MENUITEM_SEPARATOR }
308};
309
310static CMenuItem script_submenu_items_bottom[] = {
311    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
312    {0}
313};
314
315static CMenuItem script_submenu_items[sizeof(script_submenu_items_top)/sizeof(script_submenu_items_top[0])+SCRIPT_NUM_PARAMS+
316                               sizeof(script_submenu_items_bottom)/sizeof(script_submenu_items_bottom[0])];
317static CMenu script_submenu = {0x27,LANG_MENU_SCRIPT_TITLE, NULL, script_submenu_items };
318
319
320static CMenuItem games_submenu_items[] = {
321#ifdef OPT_GAME_REVERSI
322    {0x38,LANG_MENU_GAMES_REVERSI,           MENUITEM_PROC,  (int*)gui_draw_reversi },
323#endif
324#ifdef OPT_GAME_SOKOBAN
325    {0x38,LANG_MENU_GAMES_SOKOBAN,           MENUITEM_PROC,  (int*)gui_draw_sokoban },
326#endif
327#ifdef OPT_GAME_CONNECT4
328    {0x38,LANG_MENU_GAMES_CONNECT4,             MENUITEM_PROC,  (int*)gui_draw_4wins },
329#endif
330#ifdef OPT_GAME_MASTERMIND
331    {0x38,LANG_MENU_GAMES_MASTERMIND,           MENUITEM_PROC,  (int*)gui_draw_mastermind },
332#endif
333    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
334    {0}
335};
336static CMenu games_submenu = {0x38,LANG_MENU_GAMES_TITLE, NULL, games_submenu_items };
337
338static CMenuItem autoiso_submenu_items[] = {
339    {0x5c,LANG_MENU_AUTOISO_ENABLED,          MENUITEM_BOOL,    &conf.autoiso_enable},
340    {0x5f,LANG_MENU_AUTOISO_MIN_SHUTTER,   MENUITEM_ENUM,    (int*)gui_autoiso_shutter_enum },
341    {0x5f,LANG_MENU_AUTOISO_USER_FACTOR,   MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.autoiso_user_factor, MENU_MINMAX(1, 8)  },
342#if CAM_HAS_IS   
343    {0x5f,LANG_MENU_AUTOISO_IS_FACTOR,       MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.autoiso_is_factor, MENU_MINMAX(1, 8)  },
344#endif   
345    {0x5f,LANG_MENU_AUTOISO_MAX_ISO_HI,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.autoiso_max_iso_hi, MENU_MINMAX(20, 160)  },
346    {0x5f,LANG_MENU_AUTOISO_MAX_ISO_AUTO, MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.autoiso_max_iso_auto, MENU_MINMAX(10, 80)  },
347    {0x5f,LANG_MENU_AUTOISO_MIN_ISO,           MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.autoiso_min_iso, MENU_MINMAX(1, 20)  },
348    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
349    {0}
350};
351static CMenu autoiso_submenu = {0x2d,LANG_MENU_AUTOISO_TITLE, NULL, autoiso_submenu_items };
352
353
354#ifdef OPT_TEXTREADER
355static CMenuItem reader_submenu_items[] = {
356    {0x35,LANG_MENU_READ_OPEN_NEW,           MENUITEM_PROC,    (int*)gui_draw_read },
357    {0x35,LANG_MENU_READ_OPEN_LAST,          MENUITEM_PROC,    (int*)gui_draw_read_last },
358    {0x35,LANG_MENU_READ_SELECT_FONT,        MENUITEM_PROC,    (int*)gui_draw_load_rbf },
359    {0x5f,LANG_MENU_READ_CODEPAGE,           MENUITEM_ENUM,    (int*)gui_reader_codepage_enum },
360    {0x5c,LANG_MENU_READ_WORD_WRAP,          MENUITEM_BOOL,    &conf.reader_wrap_by_words },
361    {0x5c,LANG_MENU_READ_AUTOSCROLL,         MENUITEM_BOOL,    &conf.reader_autoscroll },
362    {0x5f,LANG_MENU_READ_AUTOSCROLL_DELAY,   MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.reader_autoscroll_delay, MENU_MINMAX(0, 60) },
363    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
364    {0}
365};
366static CMenu reader_submenu = {0x37,LANG_MENU_READ_TITLE, NULL, reader_submenu_items };
367#endif
368
369#ifdef OPT_DEBUGGING
370static CMenuItem debug_submenu_items[] = {
371    {0x5c,LANG_MENU_DEBUG_DISPLAY,           MENUITEM_ENUM,          (int*)gui_debug_display_enum },
372    {0x2a,LANG_MENU_DEBUG_PROPCASE_PAGE,     MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,   &debug_propcase_page, MENU_MINMAX(0, 128) },
373    {0x2a,LANG_MENU_DEBUG_TASKLIST_START,    MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,   &debug_tasklist_start, MENU_MINMAX(0, 63) },
374    {0x5c,LANG_MENU_DEBUG_SHOW_MISC_VALS,    MENUITEM_BOOL,          &debug_vals_show },
375    {0x2a,LANG_MENU_DEBUG_MEMORY_BROWSER,    MENUITEM_PROC,          (int*)gui_draw_debug },
376    {0x2a,LANG_MENU_DEBUG_BENCHMARK,         MENUITEM_PROC,          (int*)gui_draw_bench },
377    {0x5c,LANG_MENU_DEBUG_SHORTCUT_ACTION,   MENUITEM_ENUM,          (int*)gui_debug_shortcut_enum },
378    {0x5c,LANG_MENU_RAW_TIMER,               MENUITEM_BOOL,          &conf.raw_timer },
379#if CAM_MULTIPART
380    {0x33,LANG_MENU_DEBUG_CREATE_MULTIPART , MENUITEM_PROC,             (int*)gui_menuproc_break_card },
381#endif
382    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
383    {0}
384};
385static CMenu debug_submenu = {0x2a,LANG_MENU_DEBUG_TITLE, NULL, debug_submenu_items };
386#endif
387
388
389static CMenuItem misc_submenu_items[] = {
390    {0x35,LANG_MENU_MISC_FILE_BROWSER,       MENUITEM_PROC,    (int*)gui_draw_fselect },
391#ifdef OPT_CALENDAR
392    {0x36,LANG_MENU_MISC_CALENDAR,           MENUITEM_PROC,    (int*)gui_draw_calendar },
393#endif
394#ifdef OPT_TEXTREADER
395    {0x37,LANG_MENU_MISC_TEXT_READER,        MENUITEM_SUBMENU, (int*)&reader_submenu },
396#endif
397#if defined (OPT_GAME_REVERSI) || (OPT_GAME_SOKOBAN || (OPT_GAME_CONNECT4) || OPT_GAME_MASTERMIND)
398    {0x38,LANG_MENU_MISC_GAMES,              MENUITEM_SUBMENU, (int*)&games_submenu },
399#endif
400#if CAM_SWIVEL_SCREEN
401    {0x28,LANG_MENU_MISC_FLASHLIGHT,         MENUITEM_BOOL,    &conf.flashlight },
402#endif
403    {0x5c,LANG_MENU_MISC_SHOW_SPLASH,        MENUITEM_BOOL,    &conf.splash_show },
404                {0x5c,LANG_MENU_MISC_START_SOUND,        MENUITEM_BOOL,    &conf.start_sound },
405#if CAM_USE_ZOOM_FOR_MF
406    {0x59,LANG_MENU_MISC_ZOOM_FOR_MF,        MENUITEM_BOOL,    &conf.use_zoom_mf },
407#endif
408#if CAM_ADJUSTABLE_ALT_BUTTON
409    {0x22,LANG_MENU_MISC_ALT_BUTTON,         MENUITEM_ENUM,    (int*)gui_alt_mode_button_enum },
410#endif
411    {0x5d,LANG_MENU_MISC_DISABLE_LCD_OFF,    MENUITEM_ENUM,    (int*)gui_alt_power_enum },
412    {0x65,LANG_MENU_MISC_PALETTE,            MENUITEM_PROC,    (int*)gui_draw_palette },
413    {0x80,LANG_MENU_MISC_BUILD_INFO,         MENUITEM_PROC,    (int*)gui_show_build_info },
414    {0x80,LANG_MENU_MISC_MEMORY_INFO,        MENUITEM_PROC,    (int*)gui_show_memory_info },
415    {0x33,LANG_MENU_DEBUG_MAKE_BOOTABLE,     MENUITEM_PROC,    (int*)gui_menuproc_mkbootdisk },
416#if CAM_MULTIPART
417    {0x33,LANG_MENU_DEBUG_SWAP_PART,         MENUITEM_PROC,             (int*)gui_menuproc_swap_patitons },
418#endif
419    {0x2b,LANG_MENU_MAIN_RESET_OPTIONS,      MENUITEM_PROC,      (int*)gui_menuproc_reset },
420#ifdef OPT_DEBUGGING
421    {0x2a,LANG_MENU_MAIN_DEBUG,              MENUITEM_SUBMENU,   (int*)&debug_submenu },
422#endif
423    {0x86,LANG_MENU_REMOTE_PARAM,            MENUITEM_SUBMENU,   (int*)&remote_submenu },
424#if defined (DNG_EXT_FROM) && defined(DNG_EXT_TO)
425    {0x71,LANG_MENU_DNG_VIA_USB,        MENUITEM_BOOL | MENUITEM_ARG_CALLBACK, &conf.dng_usb_ext , (int)cb_change_dng_usb_ext},
426#endif
427    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
428    {0},
429};
430static CMenu misc_submenu = {0x29,LANG_MENU_MISC_TITLE, NULL, misc_submenu_items };
431
432static int voltage_step;
433static CMenuItem battery_submenu_items[] = {
434    {0x66,LANG_MENU_BATT_VOLT_MAX,           MENUITEM_INT|MENUITEM_ARG_ADDR_INC,     &conf.batt_volts_max,   (int)&voltage_step },
435    {0x67,LANG_MENU_BATT_VOLT_MIN,           MENUITEM_INT|MENUITEM_ARG_ADDR_INC,     &conf.batt_volts_min,   (int)&voltage_step },
436    {0x68,LANG_MENU_BATT_STEP_25,            MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,    &conf.batt_step_25,     (int)cb_step_25 },
437    {0x0,(int)"",                           MENUITEM_SEPARATOR },
438    {0x73,LANG_MENU_BATT_SHOW_PERCENT,       MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,    &conf.batt_perc_show,   (int)cb_perc },
439    {0x73,LANG_MENU_BATT_SHOW_VOLTS,         MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,    &conf.batt_volts_show,  (int)cb_volts },
440    {0x32,LANG_MENU_BATT_SHOW_ICON,          MENUITEM_BOOL,                          &conf.batt_icon_show },   
441    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
442    {0}
443};
444static CMenu battery_submenu = {0x32,LANG_MENU_BATT_TITLE, cb_battery_menu_change, battery_submenu_items };
445
446static CMenuItem space_submenu_items[] = {
447    {0x5c,LANG_MENU_SPACE_SHOW_ICON,         MENUITEM_BOOL,                          &conf.space_icon_show },
448    {0x69,LANG_MENU_SPACE_SHOW_BAR,      MENUITEM_ENUM,                       (int*)gui_space_bar_enum },
449    {0x6a,LANG_MENU_SPACE_BAR_SIZE,      MENUITEM_ENUM,                       (int*)gui_space_bar_size_enum }, 
450    {0x6b,LANG_MENU_SPACE_BAR_WIDTH,      MENUITEM_ENUM,                       (int*)gui_space_bar_width_enum },
451    {0x5c,LANG_MENU_SPACE_SHOW_PERCENT,      MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,    &conf.space_perc_show,   (int)cb_space_perc },
452    {0x5c,LANG_MENU_SPACE_SHOW_MB,           MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,    &conf.space_mb_show,  (int)cb_space_mb },
453    {0x5f,LANG_MENU_SPACE_WARN_TYPE,      MENUITEM_ENUM,                       (int*)gui_space_warn_type_enum },
454    {0x58,LANG_MENU_SPACE_WARN_PERCENT,     MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,   &conf.space_perc_warn, MENU_MINMAX(1, 99) },
455    {0x58,LANG_MENU_SPACE_WARN_MB,     MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,   &conf.space_mb_warn, MENU_MINMAX(1, 4000) },
456    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
457    {0}
458};
459static CMenu space_submenu = {0x33,LANG_MENU_OSD_SPACE_PARAMS_TITLE, NULL, space_submenu_items};
460
461static CMenuItem dof_submenu_items[] = {
462          {0x5f,LANG_MENU_OSD_SHOW_DOF_CALC,            MENUITEM_ENUM,      (int*)gui_dof_show_value_enum },
463          {0x5c,LANG_MENU_DOF_SUBJ_DIST_AS_NEAR_LIMIT,  MENUITEM_BOOL,      &conf.dof_subj_dist_as_near_limit},
464          {0x5c,LANG_MENU_DOF_USE_EXIF_SUBJ_DIST,       MENUITEM_BOOL,      &conf.dof_use_exif_subj_dist},       
465          {0x5c,LANG_MENU_DOF_SUBJ_DIST_IN_MISC,        MENUITEM_BOOL,      &conf.dof_subj_dist_in_misc},       
466          {0x5c,LANG_MENU_DOF_NEAR_LIMIT_IN_MISC,       MENUITEM_BOOL,      &conf.dof_near_limit_in_misc},     
467      {0x5c,LANG_MENU_DOF_FAR_LIMIT_IN_MISC,        MENUITEM_BOOL,                       &conf.dof_far_limit_in_misc}, 
468      {0x5c,LANG_MENU_DOF_HYPERFOCAL_IN_MISC,       MENUITEM_BOOL,      &conf.dof_hyperfocal_in_misc},                         
469      {0x5c,LANG_MENU_DOF_DEPTH_LIMIT_IN_MISC,      MENUITEM_BOOL,      &conf.dof_depth_in_misc},                       
470#if !CAM_DRYOS
471      {0x5c,LANG_MENU_DOF_DIST_FROM_LENS,           MENUITEM_BOOL,      &conf.dof_dist_from_lens},                     
472#endif     
473          {0x51,LANG_MENU_BACK,                            MENUITEM_UP },
474    {0}
475};
476static CMenu dof_submenu = {0x31,LANG_MENU_DOF_TITLE, /*cb_dof_menu_change*/ NULL, dof_submenu_items };
477
478static CMenuItem values_submenu_items[] = {
479          {0x5f,LANG_MENU_OSD_SHOW_MISC_VALUES,           MENUITEM_ENUM,      (int*)gui_show_values_enum },
480         // {0x43,LANG_MENU_VALUES_SHOW_IN_REVIEW,   MENUITEM_BOOL,      &conf.values_show_in_review},
481          {0x5c,LANG_MENU_SHOW_VALUES_IN_VIDEO,           MENUITEM_BOOL,      &conf.show_values_in_video},
482          {0x5c,LANG_MENU_VALUES_SHOW_ZOOM,               MENUITEM_BOOL,      &conf.values_show_zoom}, 
483          {0x5f,LANG_MENU_OSD_ZOOM_VALUE,                 MENUITEM_ENUM,      (int*)gui_zoom_value_enum },     
484          {0x60,LANG_MENU_OSD_ZOOM_SCALE,                 MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.zoom_scale,   MENU_MINMAX(0, 1000)},       
485      {0x62,LANG_MENU_VALUES_SHOW_REAL_APERTURE,      MENUITEM_BOOL,      &conf.values_show_real_aperture},             
486      {0x74,LANG_MENU_VALUES_SHOW_REAL_ISO,           MENUITEM_BOOL,      &conf.values_show_real_iso},                 
487      {0x74,LANG_MENU_VALUES_SHOW_MARKET_ISO,         MENUITEM_BOOL,      &conf.values_show_market_iso},                               
488          {0x2d,LANG_MENU_SHOW_ISO_ONLY_IN_AUTOISO_MODE,  MENUITEM_BOOL,             &conf.values_show_iso_only_in_autoiso_mode},                       
489      {0x5c,LANG_MENU_VALUES_SHOW_EV_SETED,                      MENUITEM_BOOL,      &conf.values_show_ev_seted},
490      {0x5c,LANG_MENU_VALUES_SHOW_EV_MEASURED,        MENUITEM_BOOL,             &conf.values_show_ev_measured},                               
491      {0x5c,LANG_MENU_VALUES_SHOW_BV_SETED,                      MENUITEM_BOOL,      &conf.values_show_bv_seted},                                       
492      {0x5c,LANG_MENU_VALUES_SHOW_BV_MEASURED,           MENUITEM_BOOL,      &conf.values_show_bv_measured},                                   
493      {0x5c,LANG_MENU_VALUES_SHOW_OVEREXPOSURE,      MENUITEM_BOOL,      &conf.values_show_overexposure},       
494      {0x5c,LANG_MENU_SHOW_CANON_OVEREXPOSURE,       MENUITEM_BOOL,      &conf.values_show_canon_overexposure},                                                 
495      {0x5c,LANG_MENU_VALUES_SHOW_LUMINANCE,         MENUITEM_BOOL,      &conf.values_show_luminance},                                                 
496          {0x51,LANG_MENU_BACK,                           MENUITEM_UP },
497    {0}
498};
499static CMenu values_submenu = {0x28,LANG_MENU_OSD_VALUES_TITLE, /*cb_values_menu_change*/ NULL, values_submenu_items };
500
501static CMenuItem clock_submenu_items[] = {
502    {0x5f,LANG_MENU_OSD_SHOW_CLOCK,          MENUITEM_ENUM,      (int*)gui_show_clock_enum },
503    {0x6d,LANG_MENU_OSD_CLOCK_FORMAT,          MENUITEM_ENUM,      (int*)gui_clock_format_enum },
504    {0x6c,LANG_MENU_OSD_CLOCK_INDICATOR,          MENUITEM_ENUM,      (int*)gui_clock_indicator_enum },
505    {0x6e,LANG_MENU_OSD_CLOCK_HALFPRESS,          MENUITEM_ENUM,      (int*)gui_clock_halfpress_enum },
506    {0x51,LANG_MENU_BACK,                           MENUITEM_UP },
507    {0}
508};
509static CMenu clock_submenu = {0x34,LANG_MENU_OSD_CLOCK_PARAMS_TITLE, NULL, clock_submenu_items };
510
511
512static CMenuItem video_submenu_items[] = {
513          {0x23,LANG_MENU_VIDEO_MODE,              MENUITEM_ENUM,    (int*)gui_video_mode_enum},
514      {0x5e,LANG_MENU_VIDEO_BITRATE,           MENUITEM_ENUM,    (int*)gui_video_bitrate_enum},
515      {0x60,LANG_MENU_VIDEO_QUALITY,           MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.video_quality, MENU_MINMAX(1, 99)},
516      {0x5c,LANG_MENU_CLEAR_VIDEO_VALUES,    MENUITEM_BOOL,    (int*)&conf.clear_video},
517#if CAM_VIDEO_CONTROL
518      {0x5c,LANG_MENU_FAST_SWITCH_VIDEO,   MENUITEM_BOOL,  &conf.fast_movie_control},
519#endif
520#if CAM_CHDK_HAS_EXT_VIDEO_MENU
521      {0x5c,LANG_MENU_FAST_SWITCH_QUALITY_VIDEO,   MENUITEM_BOOL,  &conf.fast_movie_quality_control},
522#endif
523#if CAM_CAN_UNLOCK_OPTICAL_ZOOM_IN_VIDEO
524      {0x5c,LANG_MENU_OPTICAL_ZOOM_IN_VIDEO,   MENUITEM_BOOL,  &conf.unlock_optical_zoom_for_video},                                                   
525#endif
526#if CAM_CAN_MUTE_MICROPHONE
527      {0x83,LANG_MENU_MUTE_ON_ZOOM,   MENUITEM_BOOL,  &conf.mute_on_zoom},
528#endif
529#if CAM_AF_SCAN_DURING_VIDEO_RECORD
530      {0x82,LANG_MENU_VIDEO_AF_KEY,   MENUITEM_ENUM,    (int*)gui_video_af_key_enum},
531#endif
532                {0x5c,LANG_MENU_OSD_SHOW_VIDEO_TIME,         MENUITEM_ENUM,      (int*)gui_show_movie_time },
533    {0x60,LANG_MENU_OSD_SHOW_VIDEO_REFRESH,             MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.show_movie_refresh,   MENU_MINMAX(1, 20)},
534      {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
535      {0}
536};
537static CMenu video_submenu = {0x23,LANG_MENU_VIDEO_PARAM_TITLE, NULL, video_submenu_items };
538
539static CMenuItem bracketing_in_continuous_submenu_items[] = {
540          {0x63,LANG_MENU_TV_BRACKET_VALUE,             MENUITEM_ENUM,    (int*)gui_tv_bracket_values_enum },
541#if CAM_HAS_IRIS_DIAPHRAGM
542          {0x62,LANG_MENU_AV_BRACKET_VALUE,             MENUITEM_ENUM,    (int*)gui_av_bracket_values_enum },
543#endif   
544#if CAM_CAN_SD_OVERRIDE
545          {0x5e,LANG_MENU_SUBJ_DIST_BRACKET_VALUE,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.subj_dist_bracket_value, MENU_MINMAX(0, 100)},
546          {0x5f,LANG_MENU_SUBJ_DIST_BRACKET_KOEF,       MENUITEM_ENUM,    (int*)gui_subj_dist_bracket_koef_enum},
547#endif   
548          {0x74,LANG_MENU_ISO_BRACKET_VALUE,            MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.iso_bracket_value, MENU_MINMAX(0, 100)},
549          {0x5f,LANG_MENU_ISO_BRACKET_KOEF,             MENUITEM_ENUM,    (int*)gui_iso_bracket_koef_enum},
550          {0x60,LANG_MENU_BRACKET_TYPE,                 MENUITEM_ENUM,    (int*)gui_bracket_type_enum },
551          {0x5b,LANG_MENU_CLEAR_BRACKET_VALUES,        MENUITEM_BOOL,        (int*)&conf.clear_bracket},
552     {0x5c,LANG_MENU_BRACKETING_ADD_RAW_SUFFIX,                MENUITEM_BOOL,      &conf.bracketing_add_raw_suffix },
553      {0x51,LANG_MENU_BACK,                         MENUITEM_UP },
554      {0}
555};
556static CMenu bracketing_in_continuous_submenu = {0x2c,LANG_MENU_BRACKET_IN_CONTINUOUS_TITLE, NULL, bracketing_in_continuous_submenu_items };
557
558
559/*
560static CMenuItem exposure_submenu_items[] = {
561          {0x59,LANG_MENU_RECALC_EXPOSURE,         MENUITEM_BOOL,    &conf.recalc_exposure},
562          {0x63,LANG_MENU_TV_EXPOSURE_ORDER,       MENUITEM_ENUM,    (int*)gui_tv_exposure_order_enum},
563          {0x62,LANG_MENU_AV_EXPOSURE_ORDER,       MENUITEM_ENUM,    (int*)gui_av_exposure_order_enum},
564          {0x74,LANG_MENU_ISO_EXPOSURE_ORDER,      MENUITEM_ENUM,    (int*)gui_iso_exposure_order_enum},
565          {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
566      {0}
567};
568static CMenu exposure_submenu = {0x2a,LANG_MENU_EXPOSURE_TITLE, NULL, exposure_submenu_items };
569*/
570
571static CMenuItem operation_submenu_items[] = {
572      {0x5c,LANG_MENU_OVERRIDE_DISABLE,         MENUITEM_ENUM,    (int*)gui_override_disable_enum},//&conf.override_disable }, 
573      {0x5c,LANG_MENU_OVERRIDE_DISABLE_ALL,     MENUITEM_BOOL,    &conf.override_disable_all },
574          {0x61,LANG_MENU_OVERRIDE_TV_VALUE,        MENUITEM_ENUM,    (int*)gui_tv_override_value_enum},
575          {0x5f,LANG_MENU_OVERRIDE_TV_KOEF,         MENUITEM_ENUM,    (int*)gui_tv_override_koef_enum},
576          {0x59,LANG_MENU_TV_ENUM_TYPE,             MENUITEM_ENUM,    (int*)gui_tv_enum_type_enum},
577#if CAM_HAS_IRIS_DIAPHRAGM
578          {0x62,LANG_MENU_OVERRIDE_AV_VALUE,        MENUITEM_ENUM,    (int*)gui_av_override_enum },
579#endif   
580#if CAM_HAS_ND_FILTER
581      {0x62,LANG_MENU_OVERRIDE_ND_FILTER,       MENUITEM_ENUM,    (int*)gui_nd_filter_state_enum },
582#endif     
583#if CAM_CAN_SD_OVERRIDE 
584      {0x5e,LANG_MENU_OVERRIDE_SUBJ_DIST_VALUE, MENUITEM_ENUM,    (int*)gui_subj_dist_override_value_enum},
585          {0x5f,LANG_MENU_OVERRIDE_SUBJ_DIST_KOEF,  MENUITEM_ENUM,    (int*)gui_subj_dist_override_koef_enum},
586#endif   
587          {0x74,LANG_MENU_OVERRIDE_ISO_VALUE,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.iso_override_value, MENU_MINMAX(0, 800)},
588          {0x5f,LANG_MENU_OVERRIDE_ISO_KOEF,        MENUITEM_ENUM,    (int*)gui_iso_override_koef_enum},
589#if ZOOM_OVERRIDE
590    {0x5c,LANG_MENU_OVERRIDE_ZOOM,         MENUITEM_BOOL,    &conf.zoom_override},
591    {0x5f,LANG_MENU_OVERRIDE_ZOOM_VALUE,          MENUITEM_ENUM,    (int*)gui_zoom_override_enum },   
592         
593          {0x5c,LANG_MENU_CLEAR_ZOOM_OVERRIDE_VALUES,    MENUITEM_BOOL,    (int*)&conf.clear_zoom_override},
594#endif
595          {0x2c,LANG_MENU_BRACKET_IN_CONTINUOUS,           MENUITEM_SUBMENU, (int*)&bracketing_in_continuous_submenu },
596          {0x2d,LANG_MENU_AUTOISO,                  MENUITEM_SUBMENU, (int*)&autoiso_submenu },
597      //{LANG_MENU_EXPOSURE,               MENUITEM_SUBMENU, (int*)&exposure_submenu },
598          {0x5b,LANG_MENU_CLEAR_OVERRIDE_VALUES,    MENUITEM_BOOL,    (int*)&conf.clear_override},
599 
600      {0x5c,LANG_MENU_MISC_FAST_EV,         MENUITEM_BOOL,    &conf.fast_ev },
601      {0x5f,LANG_MENU_MISC_FAST_EV_STEP,    MENUITEM_ENUM,    (int*)gui_fast_ev_step },
602#if CAM_REAR_CURTAIN
603      {0x5c, LANG_MENU_REAR_CURTAIN, MENUITEM_BOOL, &conf.flash_sync_curtain },
604#endif
605#if CAM_HAS_VIDEO_BUTTON
606                    {0x5c, LANG_MENU_FLASH_VIDEO_OVERRIDE, MENUITEM_BOOL,   &conf.flash_video_override},
607                        {0x5f, LANG_MENU_FLASH_VIDEO_OVERRIDE_POWER,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.flash_video_override_power, MENU_MINMAX(0, 2)},
608#endif
609          {0x51,LANG_MENU_BACK,                     MENUITEM_UP },
610     {0}
611};
612static CMenu operation_submenu = {0x21,LANG_MENU_OPERATION_PARAM_TITLE, NULL, operation_submenu_items };
613
614#ifdef OPT_EDGEOVERLAY
615static CMenuItem edge_overlay_submenu_items[] = {
616    {0x5c,LANG_MENU_EDGE_OVERLAY_ENABLE,     MENUITEM_BOOL,          &conf.edge_overlay_enable },
617    {0x33,LANG_MENU_EDGE_SAVE,                  MENUITEM_PROC,          (int*)gui_menuproc_edge_save },
618    {0x5c,LANG_MENU_EDGE_ZOOM,     MENUITEM_BOOL,          &conf.edge_overlay_zoom },
619    {0x5c,LANG_MENU_EDGE_LOCK,     MENUITEM_BOOL,          &conf.edge_overlay_lock },
620    {0x7f,LANG_MENU_EDGE_OVERLAY_TRESH,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX, &conf.edge_overlay_thresh, MENU_MINMAX(0, 255)},
621    {0x65,LANG_MENU_EDGE_OVERLAY_COLOR,      MENUITEM_COLOR_FG,      (int*)&conf.edge_overlay_color },
622    {0x5c,LANG_MENU_EDGE_PLAY,                  MENUITEM_BOOL,          &conf.edge_overlay_play }, //does not work on cams like s-series, which dont have a real "hardware" play/rec switch, need a workaround, probably another button
623    {0x33,LANG_MENU_EDGE_FREE,                  MENUITEM_PROC,          (int*)gui_menuproc_edge_free },
624    {0x33,LANG_MENU_EDGE_LOAD,                  MENUITEM_PROC,          (int*)gui_menuproc_edge_load },
625    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
626    {0}
627};
628static CMenu edge_overlay_submenu = {0x7f,LANG_MENU_EDGE_OVERLAY_TITLE, NULL, edge_overlay_submenu_items };
629#endif
630
631static CMenuItem grid_submenu_items[] = {
632    {0x2f,LANG_MENU_SHOW_GRID,               MENUITEM_BOOL,             &conf.show_grid_lines },
633    {0x35,LANG_MENU_GRID_LOAD,               MENUITEM_PROC,             (int*)gui_grid_lines_load },
634    {0x0,LANG_MENU_GRID_CURRENT,            MENUITEM_SEPARATOR },
635    {0x0,(int)grid_title,                   MENUITEM_TEXT },
636    {0x0,(int)"",                           MENUITEM_SEPARATOR },
637    {0x5c,LANG_MENU_GRID_FORCE_COLOR,        MENUITEM_BOOL,          &conf.grid_force_color },
638    {0x65,LANG_MENU_GRID_COLOR_LINE,         MENUITEM_COLOR_FG,      (int*)&conf.grid_color },
639    {0x65,LANG_MENU_GRID_COLOR_FILL,         MENUITEM_COLOR_BG,      (int*)&conf.grid_color },
640    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
641    {0}
642};
643static CMenu grid_submenu = {0x2f,LANG_MENU_GRID_TITLE, NULL, grid_submenu_items };
644
645static CMenuItem visual_submenu_items[] = {
646    {0x35,LANG_MENU_VIS_LANG,                MENUITEM_PROC,      (int*)gui_draw_load_lang },
647    {0x5f,LANG_MENU_VIS_OSD_FONT,            MENUITEM_ENUM,      (int*)gui_font_enum },
648    {0x35,LANG_MENU_VIS_MENU_FONT,           MENUITEM_PROC,      (int*)gui_draw_load_menu_rbf },
649    {0x35,LANG_MENU_VIS_MENU_SYMBOL_FONT,    MENUITEM_PROC,      (int*)gui_draw_load_symbol_rbf }, //AKA
650    {0x0,LANG_MENU_VIS_COLORS,              MENUITEM_SEPARATOR },
651    {0x65,LANG_MENU_VIS_OSD_TEXT,            MENUITEM_COLOR_FG,  (int*)&conf.osd_color },
652    {0x65,LANG_MENU_VIS_OSD_BKG,             MENUITEM_COLOR_BG,  (int*)&conf.osd_color },
653    {0x65,LANG_MENU_VIS_OSD_WARNING,         MENUITEM_COLOR_FG,  (int*)&conf.osd_color_warn },
654    {0x65,LANG_MENU_VIS_OSD_WARNING_BKG,     MENUITEM_COLOR_BG,  (int*)&conf.osd_color_warn },
655    {0x65,LANG_MENU_VIS_HISTO,               MENUITEM_COLOR_FG,  (int*)&conf.histo_color },
656    {0x65,LANG_MENU_VIS_HISTO_BKG,           MENUITEM_COLOR_BG,  (int*)&conf.histo_color },
657    {0x65,LANG_MENU_VIS_HISTO_BORDER,        MENUITEM_COLOR_FG,  (int*)&conf.histo_color2 },
658    {0x65,LANG_MENU_VIS_HISTO_MARKERS,       MENUITEM_COLOR_BG,  (int*)&conf.histo_color2 },
659    {0x65,LANG_MENU_VIS_ZEBRA_UNDER,         MENUITEM_COLOR_BG,  (int*)&conf.zebra_color },
660    {0x65,LANG_MENU_VIS_ZEBRA_OVER,          MENUITEM_COLOR_FG,  (int*)&conf.zebra_color },
661    {0x65,LANG_MENU_VIS_BATT_ICON,           MENUITEM_COLOR_FG,  (int*)&conf.batt_icon_color },
662    {0x65,LANG_MENU_VIS_SPACE_ICON,          MENUITEM_COLOR_FG,  (int*)&conf.space_color },
663    {0x65,LANG_MENU_VIS_SPACE_ICON_BKG,      MENUITEM_COLOR_BG,  (int*)&conf.space_color },   
664    {0x65,LANG_MENU_VIS_MENU_TEXT,           MENUITEM_COLOR_FG,  (int*)&conf.menu_color },
665    {0x65,LANG_MENU_VIS_MENU_BKG,            MENUITEM_COLOR_BG,  (int*)&conf.menu_color },
666    {0x65,LANG_MENU_VIS_MENU_TITLE_TEXT,     MENUITEM_COLOR_FG,  (int*)&conf.menu_title_color },
667    {0x65,LANG_MENU_VIS_MENU_TITLE_BKG,      MENUITEM_COLOR_BG,  (int*)&conf.menu_title_color },
668    {0x65,LANG_MENU_VIS_MENU_CURSOR_TEXT,    MENUITEM_COLOR_FG,  (int*)&conf.menu_cursor_color },
669    {0x65,LANG_MENU_VIS_MENU_CURSOR_BKG,     MENUITEM_COLOR_BG,  (int*)&conf.menu_cursor_color },
670    {0x65,LANG_MENU_VIS_MENU_SYMBOL_TEXT,    MENUITEM_COLOR_FG,  (int*)&conf.menu_symbol_color },
671    {0x65,LANG_MENU_VIS_MENU_SYMBOL_BKG,     MENUITEM_COLOR_BG,  (int*)&conf.menu_symbol_color },
672    {0x65,LANG_MENU_VIS_READER_TEXT,         MENUITEM_COLOR_FG,  (int*)&conf.reader_color },
673    {0x65,LANG_MENU_VIS_READER_BKG,          MENUITEM_COLOR_BG,  (int*)&conf.reader_color },
674    {0x65,LANG_MENU_VIS_OSD_OVERRIDE,         MENUITEM_COLOR_FG,  (int*)&conf.osd_color_override },
675    {0x65,LANG_MENU_VIS_OSD_OVERRIDE_BKG,     MENUITEM_COLOR_BG,  (int*)&conf.osd_color_override },
676    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
677    {0}
678};
679static CMenu visual_submenu = {0x28,LANG_MENU_VIS_TITLE, NULL, visual_submenu_items };
680
681/*
682 * 1 extra entry for the "Main menu" and 1 for null when the menu is full with user selections
683 * Compiler will zero init remaining portion of array so no there is no hidden relationship between
684 * this structure and the value of USER_MENU_ITEMS. The value of USER_MENU_ITEMS can be anything you
685 * wish and everything automagically works.
686*/
687 
688static CMenuItem user_submenu_items[USER_MENU_ITEMS + 2] = {
689        {0x20,LANG_MENU_MAIN_TITLE,     MENUITEM_PROC,  (int*)rinit}
690};
691 
692static CMenu user_submenu = {0x2e,LANG_MENU_USER_MENU, NULL, user_submenu_items };
693
694static CMenuItem raw_state_submenu_items[] = {
695    {0x5c,LANG_MENU_OSD_SHOW_RAW_STATE,      MENUITEM_BOOL,      &conf.show_raw_state },   
696    {0x5c,LANG_MENU_OSD_SHOW_REMAINING_RAW,  MENUITEM_BOOL,      &conf.show_remaining_raw },   
697    {0x60,LANG_MENU_OSD_RAW_TRESHOLD,        MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.remaining_raw_treshold,   MENU_MINMAX(0, 200)},
698    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
699    {0}
700};
701
702static CMenu raw_state_submenu = {0x24,LANG_MENU_OSD_RAW_STATE_PARAMS_TITLE, NULL, raw_state_submenu_items };
703
704
705static CMenuItem osd_submenu_items[] = {
706    {0x5c,LANG_MENU_OSD_SHOW,                MENUITEM_BOOL,      &conf.show_osd },
707    {0x5c,LANG_MENU_OSD_HIDE_PLAYBACK,       MENUITEM_ENUM,      (int*)gui_hide_osd_enum },
708    {0x81,LANG_MENU_VIS_MENU_CENTER,         MENUITEM_BOOL,         &conf.menu_center },
709    {0x81,LANG_MENU_SELECT_FIRST_ENTRY,         MENUITEM_BOOL,      &conf.menu_select_first_entry },       
710    {0x64,LANG_MENU_VIS_SYMBOL,             MENUITEM_BOOL,          &conf.menu_symbol_enable },   
711    {0x2e,LANG_MENU_USER_MENU,                          MENUITEM_SUBMENU,   (int*)&user_submenu},
712    {0x5f,LANG_MENU_USER_MENU_ENABLE,           MENUITEM_ENUM,      (int*)gui_user_menu_show_enum },
713    {0x5c,LANG_MENU_USER_MENU_AS_ROOT,       MENUITEM_BOOL,      &conf.user_menu_as_root },
714    {0x5f,LANG_MENU_OSD_SHOW_STATES,         MENUITEM_BOOL,      &conf.show_state },
715    {0x5f,LANG_MENU_OSD_SHOW_TEMP,         MENUITEM_ENUM,      (int*)gui_temp_mode_enum },
716    {0x59,LANG_MENU_OSD_TEMP_FAHRENHEIT,      MENUITEM_BOOL,      &conf.temperature_unit},
717    {0x72,LANG_MENU_OSD_LAYOUT_EDITOR,       MENUITEM_PROC,      (int*)gui_draw_osd_le },
718    {0x2f,LANG_MENU_OSD_GRID_PARAMS,         MENUITEM_SUBMENU,   (int*)&grid_submenu },
719    {0x22,LANG_MENU_OSD_VALUES,                 MENUITEM_SUBMENU,   (int*)&values_submenu },
720    {0x31,LANG_MENU_OSD_DOF_CALC,            MENUITEM_SUBMENU,   (int*)&dof_submenu },
721    {0x24,LANG_MENU_OSD_RAW_STATE_PARAMS,    MENUITEM_SUBMENU,   (int*)&raw_state_submenu },
722    {0x32,LANG_MENU_OSD_BATT_PARAMS,         MENUITEM_SUBMENU,   (int*)&battery_submenu },
723    {0x33,LANG_MENU_OSD_SPACE_PARAMS,        MENUITEM_SUBMENU,   (int*)&space_submenu },
724    {0x34,LANG_MENU_OSD_CLOCK_PARAMS,           MENUITEM_SUBMENU,   (int*)&clock_submenu },
725    {0x59,LANG_MENU_OSD_SHOW_IN_REVIEW,      MENUITEM_BOOL,      &conf.show_osd_in_review},
726#ifndef OPTIONS_AUTOSAVE
727    {0x5c,LANG_MENU_MAIN_SAVE_OPTIONS,       MENUITEM_PROC,      (int*)gui_menuproc_save },
728#endif
729    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
730    {0}
731};
732
733static CMenu osd_submenu = {0x22,LANG_MENU_OSD_TITLE, NULL, osd_submenu_items };
734
735static CMenuItem histo_submenu_items[] = {
736    {0x5f,LANG_MENU_HISTO_SHOW,              MENUITEM_ENUM,      (int*)gui_histo_show_enum },
737    {0x6f,LANG_MENU_HISTO_LAYOUT,            MENUITEM_ENUM,      (int*)gui_histo_layout_enum },
738    {0x5f,LANG_MENU_HISTO_MODE,              MENUITEM_ENUM,      (int*)gui_histo_mode_enum },
739    {0x5c,LANG_MENU_HISTO_EXP,               MENUITEM_BOOL,       &conf.show_overexp },
740    {0x70,LANG_MENU_HISTO_IGNORE_PEAKS,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.histo_ignore_boundary,   MENU_MINMAX(0, 32)},
741    {0x5c,LANG_MENU_HISTO_MAGNIFY,           MENUITEM_BOOL,       &conf.histo_auto_ajust },
742    {0x5c,LANG_MENU_HISTO_SHOW_EV_GRID,      MENUITEM_BOOL,       &conf.histo_show_ev_grid },
743    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
744    {0}
745};
746static CMenu histo_submenu = {0x25,LANG_MENU_HISTO_TITLE, NULL, histo_submenu_items };
747
748static CMenuItem raw_exceptions_submenu_items[] = {
749    #if defined(CAMERA_s2is) || defined(CAMERA_s3is) || defined(CAMERA_s5is)
750     {0x5c,LANG_MENU_RAW_SAVE_IN_VIDEO,                MENUITEM_BOOL,      &conf.save_raw_in_video },
751    #endif
752    #if defined(CAMERA_s3is)
753        {0x5c,LANG_MENU_RAW_SAVE_IN_SPORTS,                MENUITEM_BOOL,      &conf.save_raw_in_sports },
754    #endif
755    {0x5c,LANG_MENU_RAW_SAVE_IN_BURST,                MENUITEM_BOOL,      &conf.save_raw_in_burst },
756    {0x5c,LANG_MENU_RAW_SAVE_IN_TIMER,                MENUITEM_BOOL,      &conf.save_raw_in_timer },
757    {0x5c,LANG_MENU_RAW_SAVE_IN_EDGEOVERLAY,          MENUITEM_BOOL,      &conf.save_raw_in_edgeoverlay },
758    {0x5c,LANG_MENU_RAW_SAVE_IN_AUTO,                 MENUITEM_BOOL,      &conf.save_raw_in_auto },
759                #if CAM_BRACKETING
760        {0x5c,LANG_MENU_RAW_SAVE_IN_EV_BRACKETING,                MENUITEM_BOOL,      &conf.save_raw_in_ev_bracketing },
761                #endif
762    {0x5c,LANG_MENU_RAW_WARN,                MENUITEM_BOOL,      &conf.raw_exceptions_warn },
763    {0x51,LANG_MENU_BACK,                           MENUITEM_UP },
764    {0}
765};
766static CMenu raw_exceptions_submenu = {0x59,LANG_MENU_OSD_RAW_EXCEPTIONS_PARAMS_TITLE, NULL, raw_exceptions_submenu_items };
767
768
769static CMenuItem raw_submenu_items[] = {
770    {0x5c,LANG_MENU_RAW_SAVE,                MENUITEM_BOOL,      &conf.save_raw },
771    {0x59,LANG_MENU_OSD_RAW_EXCEPTIONS_PARAMS,          MENUITEM_SUBMENU,   (int*)&raw_exceptions_submenu },
772    {0x5f,LANG_MENU_RAW_NOISE_REDUCTION,     MENUITEM_ENUM,      (int*)gui_raw_nr_enum },
773    {0x5c,LANG_MENU_RAW_FIRST_ONLY,          MENUITEM_BOOL,      &conf.raw_save_first_only },
774    {0x5c,LANG_MENU_RAW_SAVE_IN_DIR,         MENUITEM_BOOL,      &conf.raw_in_dir },
775    {0x5f,LANG_MENU_RAW_PREFIX,              MENUITEM_ENUM,      (int*)gui_raw_prefix_enum },
776    {0x5f,LANG_MENU_RAW_EXTENSION,           MENUITEM_ENUM,      (int*)gui_raw_ext_enum },
777    {0x5f,LANG_MENU_SUB_PREFIX,              MENUITEM_ENUM,      (int*)gui_sub_batch_prefix_enum },
778    {0x5f,LANG_MENU_SUB_EXTENSION,           MENUITEM_ENUM,      (int*)gui_sub_batch_ext_enum },
779    {0x60,LANG_MENU_SUB_IN_DARK_VALUE,       MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.sub_in_dark_value, MENU_MINMAX(0, 1023)},
780    {0x60,LANG_MENU_SUB_OUT_DARK_VALUE,      MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.sub_out_dark_value, MENU_MINMAX(0, 1023)},
781    {0x2a,LANG_MENU_RAW_DEVELOP,             MENUITEM_PROC,      (int*)gui_raw_develop },
782    {0x5c,LANG_MENU_BAD_PIXEL_REMOVAL,       MENUITEM_ENUM,      (int*)gui_bad_pixel_enum },
783#if DNG_SUPPORT
784    {0x5c,LANG_MENU_DNG_FORMAT,              MENUITEM_BOOL | MENUITEM_ARG_CALLBACK, &conf.dng_raw , (int)cb_change_dng },
785    {0x5c,LANG_MENU_RAW_DNG_EXT,             MENUITEM_BOOL,      &conf.raw_dng_ext},
786#endif
787    {0x5c,LANG_MENU_RAW_CACHED,              MENUITEM_BOOL,      &conf.raw_cache },
788    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
789    {0}
790};
791static CMenu raw_submenu = {0x24,LANG_MENU_RAW_TITLE, NULL, raw_submenu_items };
792
793
794static CMenuItem zebra_submenu_items[] = {
795    {0x5c,LANG_MENU_ZEBRA_DRAW,              MENUITEM_BOOL,                            &conf.zebra_draw },
796    {0x5f,LANG_MENU_ZEBRA_MODE,              MENUITEM_ENUM,                            (int*)gui_zebra_mode_enum },
797    {0x58,LANG_MENU_ZEBRA_UNDER,             MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.zebra_under,   MENU_MINMAX(0, 32)},
798    {0x57,LANG_MENU_ZEBRA_OVER,              MENUITEM_INT|MENUITEM_F_UNSIGNED|MENUITEM_F_MINMAX,  &conf.zebra_over,    MENU_MINMAX(0, 32)},
799    {0x28,LANG_MENU_ZEBRA_RESTORE_SCREEN,    MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,      &conf.zebra_restore_screen,     (int)cb_zebra_restore_screen },
800    {0x5c,LANG_MENU_ZEBRA_RESTORE_OSD,       MENUITEM_BOOL|MENUITEM_ARG_CALLBACK,      &conf.zebra_restore_osd,        (int)cb_zebra_restore_osd },
801    {0x5f,LANG_MENU_ZEBRA_DRAW_OVER,         MENUITEM_ENUM,                            (int*)gui_zebra_draw_osd_enum },
802    {0x5c,LANG_MENU_ZEBRA_MULTICHANNEL,      MENUITEM_BOOL,                            &conf.zebra_multichannel},   
803    {0x51,LANG_MENU_BACK,                    MENUITEM_UP },
804    {0}
805};
806static CMenu zebra_submenu = {0x26,LANG_MENU_ZEBRA_TITLE, NULL, zebra_submenu_items };
807
808#ifdef OPT_CURVES
809static CMenuItem curve_submenu_items[] = {
810    {0x5f,LANG_MENU_CURVE_ENABLE,        MENUITEM_ENUM,      (int*)gui_conf_curve_enum },   
811    {0x35,LANG_MENU_CURVE_LOAD,          MENUITEM_PROC,      (int*)gui_load_curve },   
812    {0x51,LANG_MENU_BACK,                MENUITEM_UP },
813    {0}
814};
815static CMenu curve_submenu = {0x85,LANG_MENU_CURVE_PARAM_TITLE, NULL, curve_submenu_items };
816#endif
817
818static CMenuItem root_menu_items[] = {
819    {0x21,LANG_MENU_OPERATION_PARAM,         MENUITEM_SUBMENU,   (int*)&operation_submenu },
820#if CAM_CHDK_HAS_EXT_VIDEO_MENU
821    {0x23,LANG_MENU_VIDEO_PARAM,             MENUITEM_SUBMENU,   (int*)&video_submenu },
822#endif
823    {0x24,LANG_MENU_MAIN_RAW_PARAM,          MENUITEM_SUBMENU,   (int*)&raw_submenu },
824#ifdef OPT_EDGEOVERLAY
825    {0x7f,LANG_MENU_EDGE_OVERLAY,         MENUITEM_SUBMENU,   (int*)&edge_overlay_submenu },
826#endif
827#ifdef OPT_CURVES
828    {0x85,LANG_MENU_CURVE_PARAM,             MENUITEM_SUBMENU,   (int*)&curve_submenu },
829#endif
830    {0x25,LANG_MENU_MAIN_HISTO_PARAM,        MENUITEM_SUBMENU,   (int*)&histo_submenu },
831    {0x26,LANG_MENU_MAIN_ZEBRA_PARAM,        MENUITEM_SUBMENU,   (int*)&zebra_submenu },
832    {0x22,LANG_MENU_MAIN_OSD_PARAM,          MENUITEM_SUBMENU,   (int*)&osd_submenu },
833    {0x28,LANG_MENU_MAIN_VISUAL_PARAM,       MENUITEM_SUBMENU,   (int*)&visual_submenu },
834    {0x27,LANG_MENU_MAIN_SCRIPT_PARAM,       MENUITEM_SUBMENU,   (int*)&script_submenu },
835    {0x29,LANG_MENU_MAIN_MISC,               MENUITEM_SUBMENU,   (int*)&misc_submenu },
836#ifndef OPTIONS_AUTOSAVE
837    {0x33,LANG_MENU_MAIN_SAVE_OPTIONS,       MENUITEM_PROC,      (int*)gui_menuproc_save },
838#endif
839    {0}
840};
841
842static CMenu root_menu = {0x20,LANG_MENU_MAIN_TITLE, NULL, root_menu_items };
843
844static int gui_user_menu_flag;
845
846void rinit(){
847        gui_menu_init(&root_menu);
848}
849
850//-------------------------------------------------------------------
851void
852mod_user_menu(CMenuItem curr_menu_item, int* cur_memnu_item_indx, int mod) {
853int i;
854CMenuItem tmp_menu_item;
855        switch(mod) {
856
857                case 0:
858                        /*
859                         * Delete user menu entry by sliding all the lower valid/existing entries up.
860                         */
861
862                        if (*cur_memnu_item_indx == 0) /* don't allow deleting "user menu" */
863                                break;
864                        for(i = *cur_memnu_item_indx; user_submenu_items[i].text; i++) {
865                                user_submenu_items[i] = user_submenu_items[i+1];
866                        }
867 
868                        /*
869                         * there were no valid entries below this one, so
870                         * the index pointer must be decremented.
871                         */
872                        if(!user_submenu_items[*cur_memnu_item_indx].text)
873                                *cur_memnu_item_indx -= 1;
874 
875                        break;
876 
877                case 1:
878                        /*
879                         * Insert new Item at end of existing entries
880                         */
881                        for(i = 1; i < USER_MENU_ITEMS + 1; i++) {
882                                if(!user_submenu_items[i].text) {
883                                        user_submenu_items[i] = curr_menu_item;
884                                        break;
885                                }
886                        }
887                        break;
888 
889                case 2:
890                        /*
891                         * Move entry up
892                         */
893 
894                        if((*cur_memnu_item_indx > 1)) {
895                                tmp_menu_item = user_submenu_items[*cur_memnu_item_indx -1];
896                                user_submenu_items[*cur_memnu_item_indx -1] = user_submenu_items[*cur_memnu_item_indx];
897                                user_submenu_items[*cur_memnu_item_indx] = tmp_menu_item;
898                                *cur_memnu_item_indx -=1;
899                        }
900                        break;
901
902                case 3:
903                        /*
904                         * Move entry down below next entry if next entry is not empty
905                         */
906                        if (*cur_memnu_item_indx == 0) /* don't allow moving "user menu" */
907                                break;
908                        if((*cur_memnu_item_indx < (USER_MENU_ITEMS)) && (user_submenu_items[*cur_memnu_item_indx +1].text)) {
909                                tmp_menu_item = user_submenu_items[*cur_memnu_item_indx +1];
910                                user_submenu_items[*cur_memnu_item_indx + 1] = user_submenu_items[*cur_memnu_item_indx];
911                                user_submenu_items[*cur_memnu_item_indx] = tmp_menu_item;
912                                *cur_memnu_item_indx +=1;
913                        }
914                        break;
915 
916        }       
917}
918
919//-------------------------------------------------------------------
920void cb_step_25() {
921    voltage_step = (conf.batt_step_25)?25:1;
922}
923
924void cb_perc() {
925    conf.batt_volts_show=0;
926}
927
928void cb_volts() {
929    conf.batt_perc_show=0;
930}
931
932void cb_space_perc() {
933    conf.space_mb_show=0;
934}
935
936void cb_space_mb() {
937    conf.space_perc_show=0;
938}
939
940void cb_battery_menu_change(unsigned int item) {
941    switch (item) {
942        case 0: //Voltage MAX
943            if (conf.batt_volts_max<conf.batt_volts_min+25) {
944                conf.batt_volts_min = conf.batt_volts_max-25;
945            }
946            break;
947        case 1: //Voltage MIN
948            if (conf.batt_volts_min>conf.batt_volts_max-25) {
949                conf.batt_volts_max = conf.batt_volts_min+25;
950            }
951            break;
952        default:
953            break;
954    }
955}
956
957void cb_zebra_restore_screen() {
958    if (!conf.zebra_restore_screen)
959        conf.zebra_restore_osd = 0;
960}
961
962void cb_zebra_restore_osd() {
963    if (conf.zebra_restore_osd)
964        conf.zebra_restore_screen = 1;
965}
966
967#if DNG_SUPPORT
968void cb_change_dng(){
969 int old=conf.dng_raw;
970 conf_change_dng();
971 if ((old==1) && (conf.dng_raw==0)) gui_mbox_init(LANG_ERROR, LANG_CANNOT_OPEN_BADPIXEL_FILE, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL);
972}
973#endif
974
975#if defined (DNG_EXT_FROM) && defined(DNG_EXT_TO)
976void cb_change_dng_usb_ext(){
977 if (conf.dng_usb_ext) change_ext_to_dng(); else change_ext_to_default();
978}
979#endif
980
981
982//-------------------------------------------------------------------
983#ifdef OPT_CURVES
984const char* gui_conf_curve_enum(int change, int arg) {
985    static const char* modes[]={ "None", "Custom", "+1EV", "+2EV", "Auto DR" };
986
987    conf.curve_enable+=change;
988    if (conf.curve_enable<0)
989        conf.curve_enable=(sizeof(modes)/sizeof(modes[0]))-1;
990    else if (conf.curve_enable>=(sizeof(modes)/sizeof(modes[0])))
991        conf.curve_enable=0;
992
993    return modes[conf.curve_enable];
994}
995#endif
996//-------------------------------------------------------------------
997const char* gui_script_autostart_enum(int change, int arg) {
998    static const char* modes[]={ "Off", "On", "Once"};
999
1000    conf.script_startup+=change;
1001    if (conf.script_startup<0)
1002        conf.script_startup=(sizeof(modes)/sizeof(modes[0]))-1;
1003    else if (conf.script_startup>=(sizeof(modes)/sizeof(modes[0])))
1004        conf.script_startup=0;
1005
1006    return modes[conf.script_startup];
1007}
1008
1009//-------------------------------------------------------------------
1010const char* gui_script_param_set_enum(int change, int arg) {
1011    static const char* modes[]={ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
1012
1013    if (change != 0) {
1014        if (conf.script_param_save) {
1015            save_params_values(0);
1016        }
1017        conf.script_param_set += change;
1018        if (conf.script_param_set < 0)
1019            conf.script_param_set = (sizeof(modes)/sizeof(modes[0]))-1;
1020        else if (conf.script_param_set >= (sizeof(modes)/sizeof(modes[0])))
1021            conf.script_param_set=0;
1022
1023        if (!load_params_values(conf.script_file, 1, 0))
1024            script_load(conf.script_file, 0);
1025        gui_update_script_submenu();
1026    }
1027
1028    return modes[conf.script_param_set];
1029}
1030
1031
1032//-------------------------------------------------------------------
1033const char* gui_override_disable_enum(int change, int arg) {
1034    static const char* modes[]={ "Off", "On", "Disabled"};
1035
1036    conf.override_disable+=change;
1037    if (conf.override_disable<0)
1038        conf.override_disable=(sizeof(modes)/sizeof(modes[0]))-1;
1039    else if (conf.override_disable>=(sizeof(modes)/sizeof(modes[0])))
1040        conf.override_disable=0;
1041
1042    return modes[conf.override_disable];
1043}
1044
1045//-------------------------------------------------------------------
1046const char* gui_histo_mode_enum(int change, int arg) {
1047    static const char* modes[]={ "Linear", "Log" };
1048
1049    conf.histo_mode+=change;
1050    if (conf.histo_mode<0)
1051        conf.histo_mode=(sizeof(modes)/sizeof(modes[0]))-1;
1052    else if (conf.histo_mode>=(sizeof(modes)/sizeof(modes[0])))
1053        conf.histo_mode=0;
1054
1055    histogram_set_mode(conf.histo_mode);
1056
1057    return modes[conf.histo_mode];
1058}
1059
1060//-------------------------------------------------------------------
1061const char* gui_temp_mode_enum(int change, int arg) {
1062    static const char* modes[]={ "Off", "Optical","CCD","Battery","all" };
1063
1064    conf.show_temp+=change;
1065    if (conf.show_temp<0)
1066        conf.show_temp=(sizeof(modes)/sizeof(modes[0]))-1;
1067    else if (conf.show_temp>=(sizeof(modes)/sizeof(modes[0])))
1068        conf.show_temp=0;
1069
1070    return modes[conf.show_temp];
1071}
1072
1073//-------------------------------------------------------------------
1074const char* gui_histo_layout_enum(int change, int arg) {
1075    static const char* modes[]={ "RGB", "Y", "RGB Y",  "R G B", "RGB all", "Y all", "Blend", "Blend Y"};
1076
1077    conf.histo_layout+=change;
1078    if (conf.histo_layout<0)
1079        conf.histo_layout=(sizeof(modes)/sizeof(modes[0]))-1;
1080    else if (conf.histo_layout>=(sizeof(modes)/sizeof(modes[0])))
1081        conf.histo_layout=0;
1082
1083    if (conf.histo_layout==OSD_HISTO_LAYOUT_Y || conf.histo_layout==OSD_HISTO_LAYOUT_Y_argb) {
1084        histogram_set_main(HISTO_Y);
1085    } else {
1086        histogram_set_main(HISTO_RGB);
1087    }
1088
1089    return modes[conf.histo_layout];
1090}
1091
1092//-------------------------------------------------------------------
1093const char* gui_font_enum(int change, int arg) {
1094    static const char* fonts[]={ "Win1250", "Win1251", "Win1252", "Win1254", "Win1257"};
1095
1096    conf.font_cp+=change;
1097    if (conf.font_cp<0)
1098        conf.font_cp=(sizeof(fonts)/sizeof(fonts[0]))-1;
1099    else if (conf.font_cp>=(sizeof(fonts)/sizeof(fonts[0])))
1100        conf.font_cp=0;
1101
1102    if (change != 0) {
1103        font_set(conf.font_cp);
1104        if (!rbf_load(conf.menu_rbf_file))
1105            rbf_load_from_8x16(current_font);
1106        rbf_set_codepage(FONT_CP_WIN);
1107        gui_menu_init(NULL);
1108    }
1109
1110    return fonts[conf.font_cp];
1111}
1112
1113//-------------------------------------------------------------------
1114const char* gui_raw_prefix_enum(int change, int arg) {
1115    conf.raw_prefix+=change;
1116    if (conf.raw_prefix<0)
1117        conf.raw_prefix=NUM_IMG_PREFIXES-1;
1118    else if (conf.raw_prefix>=NUM_IMG_PREFIXES)
1119        conf.raw_prefix=0;
1120
1121    return img_prefixes[conf.raw_prefix];
1122}
1123
1124//-------------------------------------------------------------------
1125const char* gui_raw_ext_enum(int change, int arg) {
1126    conf.raw_ext+=change;
1127    if (conf.raw_ext<0)
1128        conf.raw_ext=NUM_IMG_EXTS-1;
1129    else if (conf.raw_ext>=NUM_IMG_EXTS)
1130        conf.raw_ext=0;
1131
1132    return img_exts[conf.raw_ext];
1133}
1134
1135//-------------------------------------------------------------------
1136const char* gui_sub_batch_prefix_enum(int change, int arg) {
1137    conf.sub_batch_prefix+=change;
1138    if (conf.sub_batch_prefix<0)
1139        conf.sub_batch_prefix=NUM_IMG_PREFIXES-1;
1140    else if (conf.sub_batch_prefix>=NUM_IMG_PREFIXES)
1141        conf.sub_batch_prefix=0;
1142
1143    return img_prefixes[conf.sub_batch_prefix];
1144}
1145
1146//-------------------------------------------------------------------
1147const char* gui_sub_batch_ext_enum(int change, int arg) {
1148    conf.sub_batch_ext+=change;
1149    if (conf.sub_batch_ext<0)
1150        conf.sub_batch_ext=NUM_IMG_EXTS-1;
1151    else if (conf.sub_batch_ext>=NUM_IMG_EXTS)
1152        conf.sub_batch_ext=0;
1153
1154    return img_exts[conf.sub_batch_ext];
1155}
1156
1157//-------------------------------------------------------------------
1158const char* gui_raw_nr_enum(int change, int arg) {
1159    static const char* modes[]={ "Auto", "Off", "On"};
1160
1161    conf.raw_nr+=change;
1162    if (conf.raw_nr<0)
1163        conf.raw_nr=(sizeof(modes)/sizeof(modes[0]))-1;
1164    else if (conf.raw_nr>=(sizeof(modes)/sizeof(modes[0])))
1165        conf.raw_nr=0;
1166
1167    return modes[conf.raw_nr];
1168}
1169
1170//-------------------------------------------------------------------
1171#ifdef OPT_TEXTREADER
1172const char* gui_reader_codepage_enum(int change, int arg) {
1173    static const char* cps[]={ "Win1251", "DOS"};
1174
1175    conf.reader_codepage+=change;
1176    if (conf.reader_codepage<0)
1177        conf.reader_codepage=(sizeof(cps)/sizeof(cps[0]))-1;
1178    else if (conf.reader_codepage>=(sizeof(cps)/sizeof(cps[0])))
1179        conf.reader_codepage=0;
1180
1181    return cps[conf.reader_codepage];
1182}
1183#endif
1184//-------------------------------------------------------------------
1185const char* gui_autoiso_shutter_enum(int change, int arg) {
1186    static const char* shutter[]={ "Auto", "1/8s", "1/15s", "1/30s", "1/60s", "1/125s", "1/250s", "1/500s", "1/1000s"};
1187
1188    conf.autoiso_shutter+=change;
1189    if (conf.autoiso_shutter<0)
1190        conf.autoiso_shutter=(sizeof(shutter)/sizeof(shutter[0]))-1;
1191    else if (conf.autoiso_shutter>=(sizeof(shutter)/sizeof(shutter[0])))
1192        conf.autoiso_shutter=0;
1193
1194    return shutter[conf.autoiso_shutter];
1195}
1196
1197//-------------------------------------------------------------------
1198const char* gui_zebra_mode_enum(int change, int arg) {
1199    static const char* modes[]={ "Blink 1", "Blink 2", "Blink 3", "Solid", "Zebra 1", "Zebra 2" };
1200
1201    conf.zebra_mode+=change;
1202    if (conf.zebra_mode<0)
1203        conf.zebra_mode=(sizeof(modes)/sizeof(modes[0]))-1;
1204    else if (conf.zebra_mode>=(sizeof(modes)/sizeof(modes[0])))
1205        conf.zebra_mode=0;
1206
1207    return modes[conf.zebra_mode];
1208}
1209
1210//-------------------------------------------------------------------
1211const char* gui_zebra_draw_osd_enum(int change, int arg) {
1212    static const char* modes[]={ "Nothing", "Histo", "OSD" };
1213
1214    conf.zebra_draw_osd+=change;
1215    if (conf.zebra_draw_osd<0)
1216        conf.zebra_draw_osd=(sizeof(modes)/sizeof(modes[0]))-1;
1217    else if (conf.zebra_draw_osd>=(sizeof(modes)/sizeof(modes[0])))
1218        conf.zebra_draw_osd=0;
1219
1220    return modes[conf.zebra_draw_osd];
1221}
1222
1223//-------------------------------------------------------------------
1224const char* gui_zoom_value_enum(int change, int arg) {
1225    static const char* modes[]={ "X", "FL", "EFL" };
1226
1227    conf.zoom_value+=change;
1228    if (conf.zoom_value<0)
1229        conf.zoom_value=(sizeof(modes)/sizeof(modes[0]))-1;
1230    else if (conf.zoom_value>=(sizeof(modes)/sizeof(modes[0])))
1231        conf.zoom_value=0;
1232
1233    return modes[conf.zoom_value];
1234}
1235
1236const char* gui_show_values_enum(int change, int arg) {
1237    static const char* modes[]={ "Don't", "Always", "Shoot" };
1238
1239    conf.show_values+=change;
1240    if (conf.show_values<0)
1241        conf.show_values=(sizeof(modes)/sizeof(modes[0]))-1;
1242    else if (conf.show_values>=(sizeof(modes)/sizeof(modes[0])))
1243        conf.show_values=0;
1244
1245    return modes[conf.show_values];
1246}
1247
1248const char* gui_nd_filter_state_enum(int change, int arg) {
1249    static const char* modes[]={ "Off", "In", "Out" };
1250
1251    conf.nd_filter_state+=change;
1252    if (conf.nd_filter_state<0)
1253        conf.nd_filter_state=(sizeof(modes)/sizeof(modes[0]))-1;
1254    else if (conf.nd_filter_state>=(sizeof(modes)/sizeof(modes[0])))
1255        conf.nd_filter_state=0;
1256
1257    return modes[conf.nd_filter_state];
1258}
1259
1260
1261
1262const char* gui_dof_show_value_enum(int change, int arg) {
1263    static const char* modes[]={ "Don't", "Separate", "In Misc" };
1264
1265    conf.show_dof+=change;
1266    if (conf.show_dof<0)
1267        conf.show_dof=(sizeof(modes)/sizeof(modes[0]))-1;
1268    else if (conf.show_dof>=(sizeof(modes)/sizeof(modes[0])))
1269        conf.show_dof=0;
1270
1271    return modes[conf.show_dof];
1272}
1273
1274
1275const char* gui_histo_show_enum(int change, int arg) {
1276    static const char* modes[]={ "Don't", "Always", "Shoot" };
1277
1278    conf.show_histo+=change;
1279    if (conf.show_histo<0)
1280        conf.show_histo=(sizeof(modes)/sizeof(modes[0]))-1;
1281    else if (conf.show_histo>=(sizeof(modes)/sizeof(modes[0])))
1282        conf.show_histo=0;
1283
1284    return modes[conf.show_histo];
1285}
1286
1287const char* gui_show_clock_enum(int change, int arg) {
1288    static const char* modes[]={ "Don't", "Normal", "Seconds"};
1289
1290    conf.show_clock+=change;
1291    if (conf.show_clock<0)
1292        conf.show_clock=(sizeof(modes)/sizeof(modes[0]))-1;
1293    else if (conf.show_clock>=(sizeof(modes)/sizeof(modes[0])))
1294        conf.show_clock=0;
1295
1296    return modes[conf.show_clock];
1297}
1298
1299const char* gui_hide_osd_enum(int change, int arg) {
1300    static const char* modes[]={ "Don't", "In Playback", "On Disp Press", "both"};
1301
1302    conf.hide_osd+=change;
1303    if (conf.hide_osd<0)
1304        conf.hide_osd=(sizeof(modes)/sizeof(modes[0]))-1;
1305    else if (conf.hide_osd>=(sizeof(modes)/sizeof(modes[0])))
1306        conf.hide_osd=0;
1307
1308    return modes[conf.hide_osd];
1309}
1310
1311const char* gui_clock_format_enum(int change, int arg) {
1312    static const char* modes[]={ "24h", "12h"};
1313
1314    conf.clock_format+=change;
1315    if (conf.clock_format<0)
1316        conf.clock_format=(sizeof(modes)/sizeof(modes[0]))-1;
1317    else if (conf.clock_format>=(sizeof(modes)/sizeof(modes[0])))
1318        conf.clock_format=0;
1319
1320    return modes[conf.clock_format];
1321}
1322
1323const char* gui_clock_indicator_enum(int change, int arg) {
1324    static const char* modes[]={ "PM", "P","."};
1325
1326    conf.clock_indicator+=change;
1327    if (conf.clock_indicator<0)
1328        conf.clock_indicator=(sizeof(modes)/sizeof(modes[0]))-1;
1329    else if (conf.clock_indicator>=(sizeof(modes)/sizeof(modes[0])))
1330        conf.clock_indicator=0;
1331
1332    return modes[conf.clock_indicator];
1333}
1334
1335const char* gui_clock_halfpress_enum(int change, int arg) {
1336    static const char* modes[]={ "Full", "Seconds","Don't"};
1337
1338    conf.clock_halfpress+=change;
1339    if (conf.clock_halfpress<0)
1340        conf.clock_halfpress=(sizeof(modes)/sizeof(modes[0]))-1;
1341    else if (conf.clock_halfpress>=(sizeof(modes)/sizeof(modes[0])))
1342        conf.clock_halfpress=0;
1343
1344    return modes[conf.clock_halfpress];
1345}
1346
1347const char* gui_space_bar_enum(int change, int arg) {
1348    static const char* modes[]={ "Don't", "Horizontal", "Vertical"};
1349
1350    conf.space_bar_show+=change;
1351    if (conf.space_bar_show<0)
1352        conf.space_bar_show=(sizeof(modes)/sizeof(modes[0]))-1;
1353    else if (conf.space_bar_show>=(sizeof(modes)/sizeof(modes[0])))
1354        conf.space_bar_show=0;
1355
1356    return modes[conf.space_bar_show];
1357}
1358
1359const char* gui_space_bar_size_enum(int change, int arg) {
1360    static const char* modes[]={ "1/4", "1/2", "1"};
1361
1362    conf.space_bar_size+=change;
1363    if (conf.space_bar_size<0)
1364        conf.space_bar_size=(sizeof(modes)/sizeof(modes[0]))-1;
1365    else if (conf.space_bar_size>=(sizeof(modes)/sizeof(modes[0])))
1366        conf.space_bar_size=0;
1367
1368    return modes[conf.space_bar_size];
1369}
1370
1371const char* gui_space_bar_width_enum(int change, int arg) {
1372    static const char* modes[]={ "1", "2", "3","4","5","6","7","8","9","10"};
1373
1374    conf.space_bar_width+=change;
1375    if (conf.space_bar_width<0)
1376        conf.space_bar_width=(sizeof(modes)/sizeof(modes[0]))-1;
1377    else if (conf.space_bar_width>=(sizeof(modes)/sizeof(modes[0])))
1378        conf.space_bar_width=0;
1379
1380    return modes[conf.space_bar_width];
1381}
1382
1383const char* gui_space_warn_type_enum(int change, int arg) {
1384    static const char* modes[]={ "Percent", "MB", "Don't"};
1385
1386    conf.space_warn_type+=change;
1387    if (conf.space_warn_type<0)
1388        conf.space_warn_type=(sizeof(modes)/sizeof(modes[0]))-1;
1389    else if (conf.space_warn_type>=(sizeof(modes)/sizeof(modes[0])))
1390        conf.space_warn_type=0;
1391
1392    return modes[conf.space_warn_type];
1393}
1394
1395 const char* gui_show_movie_time(int change, int arg) {
1396     static const char* modes[]={ "Don't", "hh:mm:ss", "KB/s","both"};
1397 
1398     conf.show_movie_time+=change;
1399     if (conf.show_movie_time<0)
1400         conf.show_movie_time=(sizeof(modes)/sizeof(modes[0]))-1;
1401     else if (conf.show_movie_time>=(sizeof(modes)/sizeof(modes[0])))
1402         conf.show_movie_time=0;
1403 
1404     return modes[conf.show_movie_time];
1405 }
1406
1407//-------------------------------------------------------------------
1408#if CAM_ADJUSTABLE_ALT_BUTTON
1409const char* gui_alt_mode_button_enum(int change, int arg) {
1410#if defined(CAMERA_s2is) || defined(CAMERA_s3is) || defined(CAMERA_s5is)
1411    static const char* names[]={ "Shrtcut", "Flash", "Timer", "ISO", "Video" };
1412    static const int keys[]={ KEY_PRINT, KEY_FLASH, KEY_TIMER, KEY_ISO, KEY_VIDEO };
1413#elif defined(CAMERA_g7)
1414    static const char* names[]={ "Print", "FE"};
1415    static const int keys[]={ KEY_PRINT, KEY_MICROPHONE };
1416#elif defined(CAMERA_g9)
1417    static const char* names[]={ "Print", "FE"};
1418    static const int keys[]={ KEY_PRINT,  KEY_MICROPHONE };
1419#elif defined(CAMERA_a650)
1420    static const char* names[]={ "Print", "ISO"};
1421    static const int keys[]={ KEY_PRINT, KEY_ISO };
1422#elif defined(CAMERA_sx100is)
1423    static const char* names[]={ "Print", "Face"};
1424    static const int keys[]={ KEY_PRINT, KEY_FACE };
1425#else
1426    #error camera alt-buttons not defined
1427#endif
1428    int i;
1429
1430    for (i=0; i<sizeof(names)/sizeof(names[0]); ++i) {
1431        if (conf.alt_mode_button==keys[i]) {
1432            break;
1433        }
1434    }
1435
1436    i+=change;
1437    if (i<0)
1438        i=(sizeof(names)/sizeof(names[0]))-1;
1439    else if (i>=(sizeof(names)/sizeof(names[0])))
1440        i=0;
1441
1442    conf.alt_mode_button = keys[i];
1443    kbd_set_alt_mode_key_mask(conf.alt_mode_button);
1444    return names[i];
1445}
1446#endif
1447
1448//-------------------------------------------------------------------
1449const char* gui_alt_power_enum(int change, int arg) {
1450    static const char* modes[]={ "No", "Alt", "Script" };
1451
1452    conf.alt_prevent_shutdown+=change;
1453    if (conf.alt_prevent_shutdown<0)
1454        conf.alt_prevent_shutdown=(sizeof(modes)/sizeof(modes[0]))-1;
1455    else if (conf.alt_prevent_shutdown>=(sizeof(modes)/sizeof(modes[0])))
1456        conf.alt_prevent_shutdown=0;
1457
1458    return modes[conf.alt_prevent_shutdown];
1459}
1460const char* gui_fast_ev_step(int change, int arg) {
1461    static const char* modes[]={"1/6 Ev","1/3 Ev","1/2 Ev", "2/3 Ev","5/6 Ev","1 Ev","1 1/6 Ev","1 1/3 Ev","1 1/2 Ev", "1 2/3 Ev","1 5/6 Ev","2 Ev","2 1/6 Ev","2 1/3 Ev","2 1/2 Ev", "2 2/3 Ev","2 5/6 Ev","3 Ev","3 1/6 Ev","3 1/3 Ev","3 1/2 Ev", "3 2/3 Ev","3 5/6 Ev","4 Ev"};
1462    conf.fast_ev_step+=change;
1463    if (conf.fast_ev_step<0)
1464        conf.fast_ev_step=(sizeof(modes)/sizeof(modes[0]))-1;
1465    else if (conf.fast_ev_step>=(sizeof(modes)/sizeof(modes[0])))
1466        conf.fast_ev_step=0;
1467    return modes[conf.fast_ev_step];
1468}
1469const char* gui_video_mode_enum(int change, int arg) {
1470    static const char* modes[]={ "Bitrate", "Quality"};
1471
1472    conf.video_mode+=change;
1473    if (conf.video_mode<0)
1474        conf.video_mode=(sizeof(modes)/sizeof(modes[0]))-1;
1475    else if (conf.video_mode>=(sizeof(modes)/sizeof(modes[0])))
1476        conf.video_mode=0;
1477
1478    return modes[conf.video_mode];
1479}
1480
1481//-------------------------------------------------------------------
1482const char* gui_video_bitrate_enum(int change, int arg) {
1483    conf.video_bitrate+=change;
1484    if (conf.video_bitrate<0)
1485        conf.video_bitrate=VIDEO_BITRATE_STEPS-1;
1486    else if (conf.video_bitrate>=VIDEO_BITRATE_STEPS)
1487        conf.video_bitrate=0;
1488
1489    shooting_video_bitrate_change(conf.video_bitrate);
1490
1491    return video_bitrate_strings[conf.video_bitrate];
1492}
1493
1494
1495//-------------------------------------------------------------------
1496const char* gui_tv_bracket_values_enum(int change, int arg) {
1497    static const char* modes[]={ "Off", "1/3 Ev","2/3 Ev", "1 Ev", "1 1/3Ev", "1 2/3Ev", "2 Ev", "2 1/3Ev", "2 2/3Ev", "3 Ev", "3 1/3Ev", "3 2/3Ev", "4 Ev"};
1498
1499    conf.tv_bracket_value+=change;
1500    if (conf.tv_bracket_value<0)
1501        conf.tv_bracket_value=sizeof(modes)/sizeof(modes[0])-1;
1502    else if (conf.tv_bracket_value>=(sizeof(modes)/sizeof(modes[0])))
1503        conf.tv_bracket_value=0;
1504
1505    return modes[conf.tv_bracket_value];
1506}
1507
1508const char* gui_av_bracket_values_enum(int change, int arg) {
1509    static const char* modes[]={ "Off", "1/3 Ev","2/3 Ev", "1 Ev", "1 1/3Ev", "1 2/3Ev", "2 Ev", "2 1/3Ev", "2 2/3Ev", "3 Ev", "3 1/3Ev", "3 2/3Ev", "4 Ev"};
1510
1511    conf.av_bracket_value+=change;
1512    if (conf.av_bracket_value<0)
1513        conf.av_bracket_value=sizeof(modes)/sizeof(modes[0])-1;
1514    else if (conf.av_bracket_value>=(sizeof(modes)/sizeof(modes[0])))
1515        conf.av_bracket_value=0;
1516
1517    return modes[conf.av_bracket_value];
1518}
1519
1520const char* gui_subj_dist_bracket_koef_enum(int change, int arg) {
1521    static const char* modes[]={"Off", "1", "10","100","1000"};
1522
1523    conf.subj_dist_bracket_koef+=change;
1524    if (conf.subj_dist_bracket_koef<0)
1525        conf.subj_dist_bracket_koef=sizeof(modes)/sizeof(modes[0])-1;
1526    else if (conf.subj_dist_bracket_koef>=(sizeof(modes)/sizeof(modes[0])))
1527        conf.subj_dist_bracket_koef=0;
1528   
1529    return modes[conf.subj_dist_bracket_koef];
1530}
1531
1532const char* gui_iso_bracket_koef_enum(int change, int arg) {
1533    static const char* modes[]={ "Off","1", "10","100"};
1534
1535    conf.iso_bracket_koef+=change;
1536    if (conf.iso_bracket_koef<0)
1537        conf.iso_bracket_koef=sizeof(modes)/sizeof(modes[0])-1;
1538    else if (conf.iso_bracket_koef>=(sizeof(modes)/sizeof(modes[0])))
1539        conf.iso_bracket_koef=0;
1540   
1541    return modes[conf.iso_bracket_koef];
1542}
1543
1544const char* gui_bracket_type_enum(int change, int arg) {
1545    static const char* modes[]={ "+/-", "-","+"};
1546
1547    conf.bracket_type+=change;
1548    if (conf.bracket_type<0)
1549        conf.bracket_type=0;
1550    else if (conf.bracket_type>=(sizeof(modes)/sizeof(modes[0])))
1551        conf.bracket_type=sizeof(modes)/sizeof(modes[0])-1;
1552
1553    return modes[conf.bracket_type];
1554}
1555
1556const char* gui_tv_override_koef_enum(int change, int arg) {
1557    static const char* modes[]={"Off", "1/100K", "1/10000", "1/1000","1/100","1/10", "1","10","100"};
1558
1559    conf.tv_override_koef+=change;
1560   if (conf.tv_enum_type) {
1561     if (conf.tv_override_koef<0)  conf.tv_override_koef=6;
1562     else if (conf.tv_override_koef>6) conf.tv_override_koef=0;
1563     else if (conf.tv_override_koef==1)  conf.tv_override_koef=6;
1564     else if (conf.tv_override_koef==5)  conf.tv_override_koef=0;
1565     else if (conf.tv_override_koef!=0 && conf.tv_override_koef!=6) conf.tv_override_koef=6;
1566     }
1567   else {
1568    if (conf.tv_override_koef<0)
1569        conf.tv_override_koef=sizeof(modes)/sizeof(modes[0])-1;
1570    else if (conf.tv_override_koef>=(sizeof(modes)/sizeof(modes[0])))
1571        conf.tv_override_koef=0;
1572    }
1573   
1574    return modes[conf.tv_override_koef];
1575}
1576
1577const char* gui_tv_override_value_enum(int change, int arg) {
1578    static const char* modes[]={"64","50.8", "40.3", "32", "25.4","20","16", "12.7", "10","8", "6.3","5","4","3.2", "2.5","2", "1.6", "1.3", "1", "0.8", "0.6", "0.5", "0.4", "0.3", "1/4", "1/5", "1/6", "1/8", "1/10", "1/13", "1/15", "1/20", "1/25", "1/30", "1/40", "1/50", "1/60", "1/80", "1/100", "1/125", "1/160", "1/200", "1/250", "1/320", "1/400", "1/500", "1/640","1/800", "1/1000", "1/1250", "1/1600","1/2000","1/2500","1/3200","1/4000", "1/5000", "1/6400", "1/8000", "1/10000", "1/12500", "1/16000", "1/20000", "1/25000", "1/32000", "1/40000", "1/50000", "1/64000","1/80000", "1/100k"};
1579    static char *buf;
1580
1581    conf.tv_override_value+=change;
1582    if (conf.tv_enum_type) {
1583       if (conf.tv_override_value<0) {
1584          conf.tv_override_value=sizeof(modes)/sizeof(modes[0])-1;
1585        }
1586       else if (conf.tv_override_value>=(sizeof(modes)/sizeof(modes[0])))
1587         conf.tv_override_value=0;
1588       return modes[conf.tv_override_value];
1589     }
1590     else
1591      {
1592       if (conf.tv_override_value<0) {
1593          conf.tv_override_value=100;
1594        }
1595       else if (conf.tv_override_value>100)  conf.tv_override_value=0;
1596       if(!buf) buf=malloc(4);
1597       if(!buf) return "";
1598       sprintf(buf, "%d",  conf.tv_override_value);
1599       return buf;
1600      }
1601}
1602
1603const char* gui_tv_enum_type_enum(int change, int arg) {
1604    static const char* modes[]={"Factor", "Ev Step"};
1605
1606    conf.tv_enum_type+=change;
1607    if (conf.tv_enum_type<0)
1608        conf.tv_enum_type=sizeof(modes)/sizeof(modes[0])-1;
1609    else if (conf.tv_enum_type>=(sizeof(modes)/sizeof(modes[0])))
1610        conf.tv_enum_type=0;
1611    if (change) {
1612      conf.tv_override_koef=6; 
1613          if (conf.tv_enum_type) 
1614             conf.tv_override_value=18;
1615          else conf.tv_override_value=1;
1616      }
1617    return modes[conf.tv_enum_type];
1618}
1619
1620
1621const char* gui_iso_override_koef_enum(int change, int arg) {
1622    static const char* modes[]={ "Off","1", "10","100"};
1623
1624    conf.iso_override_koef+=change;
1625    if (conf.iso_override_koef<0)
1626        conf.iso_override_koef=0;
1627    else if (conf.iso_override_koef>=(sizeof(modes)/sizeof(modes[0])))
1628        conf.iso_override_koef=sizeof(modes)/sizeof(modes[0])-1;
1629   
1630    return modes[conf.iso_override_koef];
1631}
1632
1633const char* gui_subj_dist_override_value_enum(int change, int arg) {
1634        static const int koef[] = {0, 1,10,100,1000};
1635    static char buf[8];
1636    conf.subj_dist_override_value+=(change*koef[conf.subj_dist_override_koef]);
1637    if (conf.subj_dist_override_value<0)
1638        conf.subj_dist_override_value=MAX_DIST;
1639    else if (conf.subj_dist_override_value>MAX_DIST)
1640        conf.subj_dist_override_value=0;
1641    sprintf(buf, "%d", (int)conf.subj_dist_override_value);
1642    return buf;
1643}
1644
1645
1646const char* gui_subj_dist_override_koef_enum(int change, int arg) {
1647    static const char* modes[]={ "Off","1", "10","100","1000"};
1648
1649    conf.subj_dist_override_koef+=change;
1650    if (conf.subj_dist_override_koef<0) conf.subj_dist_override_koef=0;
1651    else if (conf.subj_dist_override_koef>=(sizeof(modes)/sizeof(modes[0])))
1652        conf.subj_dist_override_koef=sizeof(modes)/sizeof(modes[0])-1;
1653   
1654    return modes[conf.subj_dist_override_koef];
1655}
1656
1657/*
1658const char* gui_tv_exposure_order_enum(int change, int arg) {
1659    static const char* modes[]={ "Off", "1","2", "3"};
1660
1661    conf.tv_exposure_order+=change;
1662    if (conf.tv_exposure_order<0)
1663        conf.tv_exposure_order=0;
1664    else if (conf.tv_exposure_order>=(sizeof(modes)/sizeof(modes[0])))
1665        conf.tv_exposure_order=sizeof(modes)/sizeof(modes[0])-1;
1666    if((conf.tv_exposure_order>0) && (conf.av_exposure_order==conf.tv_exposure_order))
1667     {
1668       conf.av_exposure_order=0;
1669     }
1670    if((conf.tv_exposure_order>0) && (conf.iso_exposure_order==conf.tv_exposure_order))
1671     {
1672       conf.iso_exposure_order=0;
1673     }
1674
1675    return modes[conf.tv_exposure_order];
1676}
1677
1678const char* gui_av_exposure_order_enum(int change, int arg) {
1679    static const char* modes[]={ "Off", "1","2", "3"};
1680
1681    conf.av_exposure_order+=change;
1682    if (conf.av_exposure_order<0)
1683        conf.av_exposure_order=0;
1684    else if (conf.av_exposure_order>=(sizeof(modes)/sizeof(modes[0])))
1685        conf.av_exposure_order=sizeof(modes)/sizeof(modes[0])-1;
1686    if((conf.av_exposure_order>0) && (conf.tv_exposure_order==conf.av_exposure_order))
1687     {
1688       conf.tv_exposure_order=0;
1689     }
1690    if((conf.av_exposure_order>0) && (conf.iso_exposure_order==conf.av_exposure_order))
1691     {
1692       conf.iso_exposure_order=0;
1693     }
1694    return modes[conf.av_exposure_order];
1695}
1696
1697const char* gui_iso_exposure_order_enum(int change, int arg) {
1698    static const char* modes[]={ "Off", "1","2", "3"};
1699
1700    conf.iso_exposure_order+=change;
1701    if (conf.iso_exposure_order<0)
1702        conf.iso_exposure_order=0;
1703    else if (conf.iso_exposure_order>=(sizeof(modes)/sizeof(modes[0])))
1704        conf.iso_exposure_order=sizeof(modes)/sizeof(modes[0])-1;
1705    if((conf.iso_exposure_order>0) && (conf.tv_exposure_order==conf.iso_exposure_order))
1706     {
1707       conf.tv_exposure_order=0;
1708     }
1709    if((conf.iso_exposure_order>0) && (conf.av_exposure_order==conf.iso_exposure_order))
1710     {
1711       conf.av_exposure_order=0;
1712     }
1713
1714    return modes[conf.iso_exposure_order];
1715}
1716*/
1717const char* gui_av_override_enum(int change, int arg) {
1718    static char buf[8];
1719    short prop_id;
1720    conf.av_override_value+=change;
1721    if (conf.av_override_value<0) conf.av_override_value=shooting_get_aperture_sizes_table_size()+6;
1722    else if (conf.av_override_value>shooting_get_aperture_sizes_table_size()+6) conf.av_override_value=0;
1723    if (conf.av_override_value == 0)  return "Off";
1724    else {
1725     short prop_id=shooting_get_aperture_from_av96(shooting_get_av96_override_value());         
1726         sprintf(buf, "%d.%02d", (int)prop_id/100, (int)prop_id%100 );
1727         return buf;
1728        }
1729}
1730
1731#if ZOOM_OVERRIDE
1732const char* gui_zoom_override_enum(int change, int arg) {
1733    static char buf[3];
1734    conf.zoom_override_value+=change;
1735    if (conf.zoom_override_value<0) conf.zoom_override_value=zoom_points-1;
1736    else if (conf.zoom_override_value>zoom_points-1) conf.zoom_override_value=0;
1737                sprintf(buf,"%i",conf.zoom_override_value);
1738                return buf;
1739}
1740#endif
1741
1742const char* gui_user_menu_show_enum(int change, int arg) {
1743    static const char* modes[]={ "Off", "On","On Direct", "Edit" };
1744
1745        if (conf.user_menu_enable == 3) user_menu_save();
1746
1747    conf.user_menu_enable+=change;
1748    if (conf.user_menu_enable<0)
1749        conf.user_menu_enable=(sizeof(modes)/sizeof(modes[0]))-1;
1750    else if (conf.user_menu_enable>=(sizeof(modes)/sizeof(modes[0])))
1751        conf.user_menu_enable=0;
1752
1753    return modes[conf.user_menu_enable];
1754}
1755 
1756const char* gui_video_af_key_enum(int change, int arg){
1757    static const char* names[]={ "", "Shutter", "Set"};
1758    static const int keys[]={0, KEY_SHOOT_HALF, KEY_SET };
1759    int i;
1760 
1761    for (i=0; i<sizeof(names)/sizeof(names[0]); ++i) {
1762        if (conf.video_af_key==keys[i]) {
1763            break;
1764        }
1765    }
1766 
1767    i+=change;
1768    if (i<0)
1769        i=(sizeof(names)/sizeof(names[0]))-1;
1770    else if (i>=(sizeof(names)/sizeof(names[0])))
1771        i=0;
1772 
1773    conf.video_af_key = keys[i];
1774    return names[i];
1775}
1776   
1777const char* gui_bad_pixel_enum(int change, int arg) {
1778    int modes[]={LANG_MENU_BAD_PIXEL_OFF, LANG_MENU_BAD_PIXEL_INTERPOLATION, LANG_MENU_BAD_PIXEL_RAW_CONVERTER};
1779    conf.bad_pixel_removal+=change;
1780    if (conf.bad_pixel_removal<0)
1781        conf.bad_pixel_removal=(sizeof(modes)/sizeof(modes[0]))-1;
1782    else if (conf.bad_pixel_removal>=(sizeof(modes)/sizeof(modes[0])))
1783        conf.bad_pixel_removal=0;
1784 
1785    return lang_str(modes[conf.bad_pixel_removal]);
1786}
1787 
1788//-------------------------------------------------------------------
1789void gui_update_script_submenu() {
1790    register int p=0, i;
1791
1792    for (i=0; i<sizeof(script_submenu_items_top)/sizeof(script_submenu_items_top[0]); ++p, ++i) {
1793        script_submenu_items[p]=script_submenu_items_top[i];
1794    }
1795    for (i=0; i<SCRIPT_NUM_PARAMS; ++i) {
1796        if (script_param_order[i]) {
1797            script_submenu_items[p].symbol=0x0;
1798            script_submenu_items[p].text=(int)script_params[script_param_order[i]-1];
1799            script_submenu_items[p].type=MENUITEM_INT;
1800            script_submenu_items[p].value=&conf.ubasic_vars[script_param_order[i]-1];
1801            ++p;
1802        }
1803    }
1804    for (i=0; i<sizeof(script_submenu_items_bottom)/sizeof(script_submenu_items_bottom[0]); ++p, ++i) {
1805        script_submenu_items[p]=script_submenu_items_bottom[i];
1806    }
1807}
1808
1809//-------------------------------------------------------------------
1810
1811void raw_fselect_cb(const char * filename){
1812 struct stat st;
1813 if (!filename) return;
1814 stat((char*)filename,&st);
1815 if (st.st_size!=hook_raw_size()) return;
1816 gui_mbox_init((int)"", LANG_RAW_DEVELOP_MESSAGE, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL);
1817 raw_prepare_develop((char*)filename);
1818}
1819
1820//-------------------------------------------------------------------
1821void gui_raw_develop(int arg){
1822 int m=mode_get();
1823 gui_fselect_init(LANG_RAW_DEVELOP_SELECT_FILE, "A/DCIM", raw_fselect_cb);
1824}
1825
1826//-------------------------------------------------------------------
1827#ifdef OPT_DEBUGGING
1828#define TASKLIST_MAX_LINES 12 // probably as much as will fit on screen
1829#define TASKLIST_NUM_TASKS 64 // should be enough ?
1830static void gui_debug_draw_tasklist(void) {
1831#ifndef CAM_DRYOS
1832    int tasklist[TASKLIST_NUM_TASKS]; // max number of tasks we will look at
1833    char buf[40]; // a single line of the list
1834    int n_tasks,n_show_tasks,show_start;
1835    const char *name;
1836    int i;
1837    n_tasks = task_id_list_get(tasklist,sizeof(tasklist)/sizeof(tasklist[0]));
1838    show_start = debug_tasklist_start;
1839    n_show_tasks = n_tasks - show_start;
1840    // auto adjust to show the last N tasks
1841    if(n_show_tasks < TASKLIST_MAX_LINES) {
1842        show_start = n_tasks - TASKLIST_MAX_LINES;
1843        if(show_start<0)
1844            show_start = 0;
1845         n_show_tasks = n_tasks - show_start;
1846    }
1847    else if( n_show_tasks > TASKLIST_MAX_LINES ) {
1848        n_show_tasks = TASKLIST_MAX_LINES;
1849    }
1850    sprintf(buf,"%d-%d of %d tasks %c",show_start,show_start+n_show_tasks,n_tasks,debug_display_direction > 0?'+':'-');
1851    draw_string(64,0,buf, conf.osd_color);
1852    for( i = 0;  i < n_show_tasks; i++ ) {
1853        // TODO get full task info
1854        name = task_name(tasklist[show_start+i]);
1855        if ( !name || !*name ) {
1856            name = "(unknown)";
1857        }
1858        sprintf(buf,"%10s %8X",name,tasklist[show_start+i]);
1859        draw_string(64,16+16*i,buf, conf.osd_color);
1860    }
1861#endif //CAM_DRYOS
1862}
1863
1864#define DEBUG_DISPLAY_NONE 0
1865#define DEBUG_DISPLAY_PROPS 1
1866#define DEBUG_DISPLAY_PARAMS 2
1867#define DEBUG_DISPLAY_TASKS 3
1868static const char * gui_debug_shortcut_enum(int change, int arg) {
1869    static const char* modes[]={ "None", "DmpRAM", "Page", "CmpProps"};
1870
1871    conf.debug_shortcut_action += change;
1872    if (conf.debug_shortcut_action < 0)
1873        conf.debug_shortcut_action = sizeof(modes)/sizeof(modes[0])-1;
1874    else if (conf.debug_shortcut_action >= (sizeof(modes)/sizeof(modes[0])))
1875        conf.debug_shortcut_action = 0;
1876   
1877    return modes[conf.debug_shortcut_action];
1878}
1879
1880static const char * gui_debug_display_enum(int change, int arg) {
1881    static const char* modes[]={ "None", "Props", "Params", "Tasks"};
1882
1883    conf.debug_display += change;
1884    if (conf.debug_display < 0)
1885        conf.debug_display=sizeof(modes)/sizeof(modes[0])-1;
1886    else if (conf.debug_display >= (sizeof(modes)/sizeof(modes[0])))
1887        conf.debug_display = 0;
1888   
1889    return modes[conf.debug_display];
1890}
1891
1892static void gui_debug_shortcut(void) {
1893    static int lastcall = -1;
1894    int t=get_tick_count();
1895    if ( lastcall != -1) {
1896        if (t-lastcall <= 400)
1897            debug_display_direction = -debug_display_direction;
1898    }
1899    lastcall=t;
1900    switch(conf.debug_shortcut_action) {
1901        case 1:
1902            dump_memory();
1903        break;
1904        case 2:
1905            if(conf.debug_display == DEBUG_DISPLAY_TASKS) {
1906                debug_tasklist_start += debug_display_direction*(TASKLIST_MAX_LINES-2); // a little intentional overlap
1907                if(debug_tasklist_start >= TASKLIST_NUM_TASKS || debug_tasklist_start < 0)
1908                    debug_tasklist_start = 0;
1909            }
1910            else if (conf.debug_display == DEBUG_DISPLAY_PROPS || conf.debug_display == DEBUG_DISPLAY_PARAMS) {
1911                debug_propcase_page += debug_display_direction*1;
1912                if(debug_propcase_page > 128 || debug_propcase_page < 0)
1913                    debug_propcase_page = 0;
1914            }
1915        break;
1916        case 3:
1917            gui_compare_props(1);
1918        break;
1919    }
1920}
1921
1922//-------------------------------------------------------------------
1923#endif
1924
1925#if CAM_MULTIPART
1926void card_break_proc(unsigned int btn){
1927 if (btn==MBOX_BTN_YES) create_partitions();
1928}
1929
1930
1931#ifdef OPT_DEBUGGING
1932static void gui_menuproc_break_card(int arg){
1933 gui_mbox_init(LANG_WARNING, LANG_PARTITIONS_CREATE_WARNING, MBOX_BTN_YES_NO|MBOX_DEF_BTN2|MBOX_TEXT_CENTER, card_break_proc);
1934}
1935#endif
1936
1937static void gui_menuproc_swap_patitons(int arg){
1938 if (get_part_count()<2) gui_mbox_init(LANG_ERROR, LANG_ONLY_ONE_PARTITION, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL);
1939 else swap_partitions();
1940}
1941#endif
1942
1943//-------------------------------------------------------------------
1944static volatile enum Gui_Mode gui_mode;
1945static volatile int gui_restore;
1946static volatile int gui_in_redraw;
1947static int gui_splash, gui_splash_mode;
1948static char osd_buf[32];
1949#ifdef OPTIONS_AUTOSAVE
1950static Conf old_conf;
1951#endif
1952
1953//-------------------------------------------------------------------
1954void gui_init()
1955{
1956
1957    gui_mode = GUI_MODE_NONE;
1958    gui_restore = 0;
1959    gui_in_redraw = 0;
1960    if (conf.start_sound>0)
1961    {
1962        play_sound(4);
1963    }
1964    gui_splash = (conf.splash_show)?SPLASH_TIME:0;
1965    user_menu_restore();
1966    gui_lang_init();
1967    draw_init();
1968
1969    exposition_thresh = screen_size/500;
1970    voltage_step = (conf.batt_step_25)?25:1;
1971    load_bad_pixels_list("A/CHDK/badpixel");
1972    load_bad_pixels_list("A/CHDK/badpixel.txt");
1973#ifdef OPT_CURVES
1974    curve_load(conf.curve_file); // load curve upon init
1975    drcurve_load("A/CHDK/SYSCURVES.CVF"); // load system L curves
1976#endif         
1977#if ZOOM_OVERRIDE
1978// reyalp - need to do this in capt_seq
1979//              if (conf.zoom_override) shooting_set_zoom(conf.zoom_override_value);
1980#endif
1981}
1982
1983static void gui_load_edge_selected( const char* fn ) {
1984    if( fn )
1985        load_edge_overlay(fn);
1986}
1987
1988//-------------------------------------------------------------------
1989#ifdef OPT_CURVES
1990static void gui_load_curve_selected(const char *fn) {
1991    if (fn)
1992        curve_load(fn);
1993}
1994
1995//-------------------------------------------------------------------
1996void gui_load_curve(int arg) {
1997    DIR   *d;
1998    char  *path = CURVE_DIR;
1999
2000    // if exists CURVE_DIR go into
2001    d=opendir(path);
2002    if (d) {
2003        closedir(d);
2004    } else {
2005        path="A";
2006    }
2007
2008    gui_fselect_init(LANG_STR_SELECT_CURVE_FILE, path, gui_load_curve_selected);
2009}
2010
2011#endif
2012//-------------------------------------------------------------------
2013enum Gui_Mode gui_get_mode() {
2014    return gui_mode;
2015}
2016
2017//-------------------------------------------------------------------
2018void gui_set_mode(enum Gui_Mode mode) {
2019    gui_mode = mode;
2020}
2021
2022//-------------------------------------------------------------------
2023void gui_force_restore() {
2024    gui_restore = gui_in_redraw;
2025}
2026
2027static void gui_handle_splash(void) {
2028        static char *logo = NULL;
2029    static int logo_size;
2030    if (gui_splash) {
2031                static int need_logo=1; // don't use logo ptr, since we don't want to keep re-trying
2032                if(need_logo) {
2033                const char *logo_name="A/CHDK/DATA/logo.dat";
2034            FILE *fd;
2035            struct stat st;
2036                        need_logo=0;
2037            if (stat(logo_name,&st) == 0) {
2038                                logo_size=st.st_size;
2039                                logo=malloc(logo_size);
2040                                if(logo) {
2041                                        fd = fopen(logo_name, "rb");
2042                                        if(fd){
2043                                                fread(logo,1,logo_size,fd);
2044                                                fclose(fd);
2045                                        }
2046                                        else {
2047                                                free(logo);
2048                                                logo=NULL;
2049                                        }
2050                }
2051                        }
2052                }
2053        if (gui_splash>(SPLASH_TIME-4)) {
2054            gui_draw_splash(logo,logo_size);
2055           //   conf.show_osd = 0;
2056        } else if (gui_splash==1 && (mode_get()&MODE_MASK) == gui_splash_mode && (gui_mode==GUI_MODE_NONE || gui_mode==GUI_MODE_ALT)) {
2057            draw_restore();
2058           // conf.show_osd = 1; //had to uncomment in order to fix a bug with disappearing osd...
2059        }
2060        --gui_splash;
2061                if(!gui_splash) {
2062                        free(logo);
2063                }
2064    }
2065}
2066
2067//-------------------------------------------------------------------
2068void gui_redraw()
2069{
2070    enum Gui_Mode gui_mode_old;
2071    static int show_script_console=0;
2072
2073        gui_handle_splash();
2074
2075    gui_in_redraw = 1;
2076    gui_mode_old = gui_mode;
2077
2078    switch (gui_mode) {
2079        case GUI_MODE_MENU:
2080            gui_menu_draw();
2081//            draw_txt_string(20, 14, "<CNF>", MAKE_COLOR(COLOR_ALT_BG, COLOR_FG));
2082            break;
2083        case GUI_MODE_ALT:
2084            gui_draw_osd();
2085            draw_txt_string(20, 14, "<ALT>", MAKE_COLOR(COLOR_ALT_BG, COLOR_FG));
2086            if ((mode_get()&MODE_MASK) == MODE_REC) {
2087                draw_txt_string(0, 14, script_title, MAKE_COLOR(COLOR_ALT_BG, COLOR_FG));
2088                if (state_kbd_script_run) show_script_console=5;
2089                if (show_script_console) {
2090                    --show_script_console;
2091                    md_draw_grid();
2092                    script_console_draw();
2093                }
2094            }
2095            break;
2096        case GUI_MODE_NONE:
2097            gui_draw_osd();
2098            break;
2099        case GUI_MODE_PALETTE:
2100            gui_palette_draw();
2101            break;
2102        case GUI_MODE_MBOX:
2103            gui_mbox_draw();
2104            break;
2105#ifdef OPT_GAME_REVERSI
2106        case GUI_MODE_REVERSI:
2107            gui_reversi_draw();
2108            break;
2109#endif
2110#ifdef OPT_GAME_SOKOBAN
2111        case GUI_MODE_SOKOBAN:
2112            gui_sokoban_draw();
2113            break;
2114#endif
2115#ifdef OPT_GAME_CONNECT4
2116        case GUI_MODE_4WINS:
2117            gui_4wins_draw();
2118            break;
2119#endif
2120#ifdef OPT_GAME_MASTERMIND
2121        case GUI_MODE_MASTERMIND:
2122            gui_mastermind_draw();
2123            break;
2124#endif
2125#ifdef OPT_DEBUGGING
2126        case GUI_MODE_DEBUG:
2127            gui_debug_draw();
2128            break;
2129#endif
2130        case GUI_MODE_FSELECT:
2131            gui_fselect_draw();
2132            break;
2133#ifdef OPT_TEXTREADER
2134        case GUI_MODE_READ:
2135            gui_read_draw();
2136            break;
2137#endif
2138        case GUI_MODE_OSD:
2139            gui_osd_draw();
2140//            draw_txt_string(20, 14, "<OSD>", MAKE_COLOR(COLOR_ALT_BG, COLOR_FG));
2141            break;
2142#ifdef OPT_CALENDAR
2143        case GUI_MODE_CALENDAR:
2144            gui_calendar_draw();
2145            break;
2146#endif
2147#ifdef OPT_DEBUGGING
2148        case GUI_MODE_BENCH:
2149            gui_bench_draw();
2150            break;
2151#endif
2152        case GUI_MODE_MPOPUP:
2153            gui_mpopup_draw();
2154            break;
2155        default:
2156            break;
2157    }
2158   
2159    gui_in_redraw = 0;
2160    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) {
2161        gui_restore = 0;
2162        if (gui_mode != GUI_MODE_REVERSI && gui_mode != GUI_MODE_SOKOBAN && gui_mode != GUI_MODE_4WINS && gui_mode != GUI_MODE_MASTERMIND)
2163            draw_restore();
2164    }
2165}
2166
2167#ifdef OPTIONS_AUTOSAVE
2168//-------------------------------------------------------------------
2169static inline void conf_store_old_settings() {
2170    old_conf=conf;
2171}
2172
2173//-------------------------------------------------------------------
2174static inline int conf_save_new_settings_if_changed() {
2175    if (memcmp(&old_conf, &conf, sizeof(Conf)) != 0) {
2176                user_menu_save();
2177        conf_save();
2178        conf_store_old_settings();
2179        return 1;
2180    }
2181    return 0;
2182}
2183#endif
2184
2185
2186//-------------------------------------------------------------------
2187void gui_kbd_process()
2188{
2189    int clicked_key;
2190
2191    if (kbd_is_key_clicked(KEY_MENU)){
2192        switch (gui_mode) {
2193            case GUI_MODE_ALT:
2194                                if (conf.user_menu_as_root && (conf.user_menu_enable != 0)) {
2195                                if (kbd_is_key_pressed(KEY_SHOOT_HALF))
2196                                        gui_menu_init(&root_menu);
2197                                else
2198                gui_menu_init(&user_submenu);
2199                                }
2200                                else {
2201                                if ((conf.user_menu_enable != 0) && kbd_is_key_pressed(KEY_SHOOT_HALF))
2202                                        gui_menu_init(&user_submenu);
2203                                else
2204                gui_menu_init(&root_menu);
2205                                }
2206                gui_mode = GUI_MODE_MENU;
2207                draw_restore();
2208                break;
2209            case GUI_MODE_MENU:
2210#ifdef OPTIONS_AUTOSAVE
2211                conf_save_new_settings_if_changed();
2212#endif
2213                                if (gui_user_menu_flag) {
2214                        gui_mode = GUI_MODE_MENU;
2215                                        gui_user_menu_flag = 0;
2216                                        gui_menu_init(&root_menu);
2217                                }
2218                                else
2219                gui_mode = GUI_MODE_ALT;
2220                draw_restore();
2221                break;
2222            case GUI_MODE_PALETTE:
2223            case GUI_MODE_REVERSI:
2224            case GUI_MODE_SOKOBAN:
2225            case GUI_MODE_4WINS:
2226                        case GUI_MODE_MASTERMIND:
2227#ifdef OPT_DEBUGGING
2228            case GUI_MODE_DEBUG:
2229#endif
2230            case GUI_MODE_OSD:
2231#ifdef OPT_CALENDAR
2232            case GUI_MODE_CALENDAR:
2233#endif
2234            case GUI_MODE_BENCH:
2235                draw_restore();
2236                gui_mode = GUI_MODE_MENU;
2237                break;
2238            case GUI_MODE_FSELECT:
2239                gui_fselect_kbd_process();
2240                break;
2241#ifdef OPT_TEXTREADER
2242            case GUI_MODE_READ:
2243                gui_read_kbd_process();
2244                draw_restore();
2245                gui_mode = GUI_MODE_MENU;
2246                break;
2247#endif
2248            default:
2249                break;
2250        }
2251        return;
2252    }
2253   
2254    switch (gui_mode) {
2255        case GUI_MODE_ALT:
2256            if (kbd_is_key_clicked(SHORTCUT_TOGGLE_RAW)) {
2257                if (conf.debug_shortcut_action > 0) {
2258#ifdef OPT_DEBUGGING
2259 gui_debug_shortcut();
2260#endif
2261}
2262#if !CAM_HAS_ERASE_BUTTON && CAM_CAN_SD_OVERRIDE
2263                if (!shooting_get_common_focus_mode())
2264#else               
2265                                else
2266#endif                                                 
2267                                   {conf.save_raw = !conf.save_raw;
2268                    draw_restore();
2269                   }
2270#if !CAM_HAS_ERASE_BUTTON && CAM_CAN_SD_OVERRIDE
2271                                else {
2272   #if CAM_HAS_ZOOM_LEVER
2273               conf.subj_dist_override_value=MAX_DIST;
2274               shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW);
2275   #else
2276               if (conf.subj_dist_override_koef==4)
2277                  gui_subj_dist_override_koef_enum(-3,0);
2278               else
2279                  gui_subj_dist_override_koef_enum(1,0);
2280   #endif
2281                                }
2282#endif
2283            } else if (kbd_is_key_clicked(KEY_SET)) {
2284                gui_menu_init(&script_submenu);
2285                gui_mode = GUI_MODE_MENU;
2286                draw_restore();
2287            } else {
2288#if !CAM_HAS_MANUAL_FOCUS && CAM_CAN_SD_OVERRIDE
2289                        if (kbd_is_key_clicked(SHORTCUT_MF_TOGGLE)) {
2290                              if (conf.subj_dist_override_koef>0)
2291                                     conf.subj_dist_override_koef=0;
2292                              else conf.subj_dist_override_koef=1;
2293                              draw_restore();
2294                             }
2295                else if (shooting_get_common_focus_mode())
2296#elif CAM_CAN_SD_OVERRIDE
2297               if (shooting_get_common_focus_mode())
2298#endif
2299
2300#if CAM_CAN_SD_OVERRIDE           
2301                          {
2302  #if CAM_HAS_ZOOM_LEVER
2303                                if (kbd_is_key_clicked(KEY_RIGHT)) {
2304                                  gui_subj_dist_override_koef_enum(1,0);
2305    #if !CAM_HAS_MANUAL_FOCUS
2306                  if (conf.subj_dist_override_koef==0) conf.subj_dist_override_koef=1;
2307    #endif
2308                  shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW);
2309                                  }
2310                                else if (kbd_is_key_clicked(KEY_LEFT))
2311                                  {
2312                                  gui_subj_dist_override_koef_enum(-1,0);
2313    #if !CAM_HAS_MANUAL_FOCUS
2314                  if (conf.subj_dist_override_koef==0) conf.subj_dist_override_koef=1;
2315    #endif
2316                  shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW);
2317                                  }
2318                                else if (kbd_is_key_clicked(SHORTCUT_SET_INFINITY))
2319                                  {
2320                                  conf.subj_dist_override_value=MAX_DIST;       
2321                  shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW);
2322                                  }
2323                                else
2324  #endif
2325                                if (kbd_is_key_clicked(SHORTCUT_SET_HYPERFOCAL))
2326                                  {     
2327                                  int m=mode_get()&MODE_SHOOTING_MASK;
2328                                  if ((m==MODE_M) || (m==MODE_AV))
2329                                    conf.subj_dist_override_value=(int)shooting_get_hyperfocal_distance_f(shooting_get_aperture_from_av96(shooting_get_user_av96()),get_focal_length(lens_get_zoom_point()));
2330                                  else conf.subj_dist_override_value=(int)shooting_get_hyperfocal_distance();           
2331                  shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW);
2332                                  }   
2333                                else 
2334                  switch (kbd_get_autoclicked_key()) {
2335  #if CAM_HAS_ZOOM_LEVER
2336                    case KEY_ZOOM_IN:
2337  #else
2338                    case KEY_RIGHT:
2339  #endif
2340                        gui_subj_dist_override_value_enum(1,0);
2341                        shooting_set_focus(shooting_get_subject_distance_override_value(),SET_NOW);
2342                        break;
2343  #if CAM_HAS_ZOOM_LEVER
2344                    case KEY_ZOOM_OUT:
2345  #else
2346                    case KEY_LEFT:
2347  #endif
2348                        gui_subj_dist_override_value_enum(-1,0);
2349                        shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW);
2350                        break;
2351                  }
2352              }
2353#endif                           
2354            }
2355            break;
2356        case GUI_MODE_MENU:
2357            gui_menu_kbd_process();
2358            break;
2359        case GUI_MODE_PALETTE:
2360            gui_palette_kbd_process();
2361            break;
2362        case GUI_MODE_MBOX:
2363            gui_mbox_kbd_process();
2364            break;
2365#ifdef OPT_GAME_REVERSI
2366        case GUI_MODE_REVERSI:
2367            gui_reversi_kbd_process();
2368            break;
2369#endif
2370#ifdef OPT_GAME_SOKOBAN
2371        case GUI_MODE_SOKOBAN:
2372            gui_sokoban_kbd_process();
2373            break;
2374#endif
2375#ifdef OPT_GAME_CONNECT4
2376        case GUI_MODE_4WINS:
2377            gui_4wins_kbd_process();
2378            break;
2379#endif
2380#ifdef OPT_GAME_MASTERMIND
2381        case GUI_MODE_MASTERMIND:
2382            gui_mastermind_kbd_process();
2383            break;
2384#endif
2385#ifdef OPT_DEBUGGING
2386        case GUI_MODE_DEBUG:
2387            gui_debug_kbd_process();
2388            break;
2389#endif
2390        case GUI_MODE_FSELECT:
2391            gui_fselect_kbd_process();
2392            break;
2393#ifdef OPT_TEXTREADER
2394        case GUI_MODE_READ:
2395            gui_read_kbd_process();
2396            break;
2397#endif
2398        case GUI_MODE_OSD:
2399            gui_osd_kbd_process();
2400            break;
2401#ifdef OPT_CALENDAR
2402        case GUI_MODE_CALENDAR:
2403            gui_calendar_kbd_process();
2404            break;
2405#endif
2406#ifdef OPT_DEBUGGING
2407        case GUI_MODE_BENCH:
2408            gui_bench_kbd_process();
2409            break;
2410#endif
2411        case GUI_MODE_MPOPUP:
2412            gui_mpopup_kbd_process();
2413             break;
2414        default:
2415            break;
2416    }
2417}
2418
2419//-------------------------------------------------------------------
2420void gui_kbd_enter()
2421{
2422    // XXX set custom palette
2423#ifdef OPTIONS_AUTOSAVE
2424    conf_store_old_settings();
2425#endif
2426    if ((conf.alt_prevent_shutdown == ALT_PREVENT_SHUTDOWN_ALT && !state_kbd_script_run)
2427        || conf.alt_prevent_shutdown == ALT_PREVENT_SHUTDOWN_ALT_SCRIPT) {
2428        disable_shutdown();
2429    }
2430    gui_mode = GUI_MODE_ALT;
2431
2432        gui_user_menu_flag = 0;
2433        if (conf.user_menu_enable == 2) {
2434                gui_menu_init(&user_submenu);
2435                gui_mode = GUI_MODE_MENU;
2436                draw_restore();
2437                gui_user_menu_flag = 1;
2438        }
2439
2440}
2441
2442//-------------------------------------------------------------------
2443void gui_kbd_leave()
2444{
2445    // XXX restore palette
2446#ifdef OPTIONS_AUTOSAVE
2447    conf_save_new_settings_if_changed();
2448#endif
2449    ubasic_error = 0;
2450    draw_restore();
2451    if (gui_mode == GUI_MODE_READ && !rbf_load(conf.menu_rbf_file))
2452        rbf_load_from_8x16(current_font);
2453    rbf_set_codepage(FONT_CP_WIN);
2454    enable_shutdown();
2455    gui_mode = GUI_MODE_NONE;
2456}
2457//-------------------------------------------------------------------
2458 
2459void other_kbd_process(){
2460 int key;
2461#if CAM_AF_SCAN_DURING_VIDEO_RECORD
2462   
2463 if (movie_status==VIDEO_RECORD_IN_PROGRESS) {
2464  if (kbd_is_key_clicked(conf.video_af_key)) MakeAFScan();
2465 }
2466 
2467#endif
2468
2469#if CAM_CAN_UNLOCK_OPTICAL_ZOOM_IN_VIDEO
2470 // return from digital to optical zoom in video
2471#if CAM_HAS_ZOOM_LEVER
2472   key=KEY_ZOOM_OUT;
2473#else
2474   key=KEY_DOWN;
2475#endif
2476    if (conf.unlock_optical_zoom_for_video && (movie_status==VIDEO_RECORD_IN_PROGRESS) &&  kbd_is_key_clicked(key)){
2477     short x;
2478     get_property_case(PROPCASE_DIGITAL_ZOOM_STATE, &x, sizeof(x));
2479     if (x) {
2480      get_property_case(PROPCASE_DIGITAL_ZOOM_POSITION, &x, sizeof(x));
2481      if (x==0) zoom_status=ZOOM_OPTICAL_MEDIUM;
2482     }
2483    }
2484#endif
2485
2486#if CAM_EV_IN_VIDEO
2487 if ((movie_status==VIDEO_RECORD_IN_PROGRESS) && !kbd_is_key_pressed(KEY_SHOOT_HALF)){
2488  #if CAM_HAS_ERASE_BUTTON
2489  if (kbd_is_key_clicked(KEY_ERASE)){
2490  #else
2491  if (kbd_is_key_clicked(KEY_DISPLAY)){
2492  #endif
2493   set_ev_video_avail(!get_ev_video_avail());
2494  }
2495  if (get_ev_video_avail()) {
2496   if (kbd_is_key_clicked(KEY_LEFT)) {
2497    set_ev_video(get_ev_video()-1);
2498   }
2499   if (kbd_is_key_clicked(KEY_RIGHT)){
2500    set_ev_video(get_ev_video()+1);
2501   }
2502  }
2503 }
2504#endif
2505}
2506
2507//-------------------------------------------------------------------
2508//extern int xxxx, eeee;
2509//-------------------------------------------------------------------
2510void gui_draw_osd() {
2511    unsigned int m, n = 0, mode_photo, mode_video;
2512    coord x;
2513#if CAM_SWIVEL_SCREEN
2514    static int flashlight = 0;
2515#endif
2516    static int zebra = 0, zebra_init = 0, pressed = 0;
2517    static int half_disp_press_old=0;
2518    int half_disp_press;
2519   
2520    m = mode_get();
2521
2522#if CAM_SWIVEL_SCREEN
2523    if (conf.flashlight && (m&MODE_SCREEN_OPENED) && (m&MODE_SCREEN_ROTATED) && (gui_mode==GUI_MODE_NONE /* || gui_mode==GUI_MODE_ALT */)) {
2524        draw_filled_rect(0, 0, screen_width-1, screen_height-1, MAKE_COLOR(COLOR_WHITE, COLOR_WHITE));
2525        flashlight = 1;
2526    }
2527    if (flashlight) {
2528        if ((!((m&MODE_SCREEN_OPENED) && (m&MODE_SCREEN_ROTATED))) || (gui_mode!=GUI_MODE_NONE /* && gui_mode!=GUI_MODE_ALT */)) {
2529            flashlight = 0;
2530            draw_restore();
2531        }
2532        return;
2533    }
2534#endif
2535   
2536    if (kbd_is_key_pressed(KEY_SHOOT_HALF)) {
2537        if (kbd_is_key_pressed(SHORTCUT_TOGGLE_ZEBRA)) {
2538            if (!pressed) {
2539                conf.zebra_draw = !conf.zebra_draw;
2540                if (zebra && !conf.zebra_draw) {
2541                    zebra = 0;
2542                    draw_restore();
2543                }
2544                pressed = 1;
2545            }
2546        }
2547         else if (kbd_is_key_pressed(SHORTCUT_TOGGLE_HISTO)) {
2548            if (!pressed) {
2549                if (++conf.show_histo>SHOW_HALF) conf.show_histo=0;
2550                if (!conf.show_histo) {
2551                    draw_restore();
2552                }
2553                pressed = 1;
2554            }
2555        } else if (kbd_is_key_pressed(SHORTCUT_TOGGLE_OSD)) {
2556            if (!pressed) {
2557                conf.show_osd = !conf.show_osd;
2558                if (!conf.show_osd) {
2559                    draw_restore();
2560                }
2561                pressed = 1;
2562            }
2563          } else if (kbd_is_key_pressed(SHORTCUT_DISABLE_OVERRIDES)) {
2564             if (!pressed) {
2565                 if (conf.override_disable < 2) conf.override_disable = !conf.override_disable;
2566                 if (!conf.show_osd) {
2567                     draw_restore();
2568                 }
2569                 pressed = 1;
2570             }
2571        } else {
2572            pressed = 0;
2573        }
2574    } else {
2575        pressed = 0;
2576    }
2577   
2578        // TODO some of the ifs below should probably use this
2579        mode_video = MODE_IS_VIDEO(m);
2580
2581    mode_photo = (m&MODE_MASK) == MODE_PLAY ||
2582                 !( mode_video ||
2583                                 (m&MODE_SHOOTING_MASK)==MODE_STITCH);
2584
2585    half_disp_press=mode_photo && kbd_is_key_pressed(KEY_SHOOT_HALF) && kbd_is_key_pressed(KEY_DISPLAY);
2586    if (half_disp_press && ! half_disp_press_old) draw_restore();
2587    half_disp_press_old=half_disp_press;
2588    if (half_disp_press) return;
2589
2590    if (conf.zebra_draw && gui_mode==GUI_MODE_NONE && kbd_is_key_pressed(KEY_SHOOT_HALF) && mode_photo) {
2591        if (!zebra_init) {
2592            zebra_init = 1;
2593            gui_osd_zebra_init();
2594        }
2595        zebra = gui_osd_draw_zebra();
2596    }
2597    if (zebra_init && !kbd_is_key_pressed(KEY_SHOOT_HALF)) {
2598        zebra_init = 0;
2599    }
2600    if (zebra) {
2601        if (!kbd_is_key_pressed(KEY_SHOOT_HALF)) {
2602            zebra = 0;
2603            draw_restore();
2604        }
2605        return;
2606    }
2607#if !CAM_SHOW_OSD_IN_SHOOT_MENU
2608    if (!(conf.show_osd && (canon_menu_active==(int)&canon_menu_active-4) && (canon_shoot_menu_active==0)))  return;   
2609#else
2610    if (!(conf.show_osd && (canon_menu_active==(int)&canon_menu_active-4) /*&& (canon_shoot_menu_active==0)*/ ))  return;
2611#endif 
2612
2613   
2614    if ((gui_mode==GUI_MODE_NONE || gui_mode==GUI_MODE_ALT) && (
2615     (kbd_is_key_pressed(KEY_SHOOT_HALF) && ((conf.show_histo==SHOW_HALF)/* || (m&MODE_MASK) == MODE_PLAY*/)) ||
2616     ((conf.show_histo==SHOW_ALWAYS)  &&  !((m&MODE_MASK) == MODE_PLAY) && (recreview_hold==0))
2617    ) &&
2618    (mode_photo || (m&MODE_SHOOTING_MASK)==MODE_STITCH)) {
2619        gui_osd_draw_histo();
2620    }
2621
2622    if ((m&MODE_MASK) == MODE_REC && (recreview_hold==0 || conf.show_osd_in_review) ) {
2623//        m &= MODE_SHOOTING_MASK;
2624//        if (m==MODE_SCN_WATER || m==MODE_SCN_NIGHT || m==MODE_SCN_CHILD || m==MODE_SCN_PARTY || m==MODE_STITCH ||
2625//            m==MODE_SCN_GRASS || m==MODE_SCN_SNOW  || m==MODE_SCN_BEACH || m==MODE_SCN_FIREWORK || m==MODE_VIDEO)
2626//            ++n;
2627
2628        if (conf.show_grid_lines) {
2629            gui_grid_draw_osd(1);
2630        }
2631        if ((gui_mode==GUI_MODE_NONE || gui_mode==GUI_MODE_ALT) && (((kbd_is_key_pressed(KEY_SHOOT_HALF) || (state_kbd_script_run) || (shooting_get_common_focus_mode())) && (mode_photo || (m&MODE_SHOOTING_MASK)==MODE_STITCH )) || ((mode_video || movie_status > 1) && conf.show_values_in_video) )) {
2632                 
2633           if (conf.show_dof!=DOF_DONT_SHOW) gui_osd_calc_dof();
2634           
2635           if (conf.show_dof==DOF_SHOW_IN_DOF) gui_osd_draw_dof(); 
2636           
2637           if (conf.values_show_real_iso || conf.values_show_market_iso || conf.values_show_ev_seted || conf.values_show_ev_measured || conf.values_show_bv_measured || conf.values_show_bv_seted || conf.values_show_overexposure || conf.values_show_canon_overexposure || conf.values_show_luminance) gui_osd_calc_expo_param();                       
2638        }
2639        if (conf.show_state) gui_osd_draw_state();
2640        if (conf.save_raw && conf.show_raw_state && !mode_video && (!kbd_is_key_pressed(KEY_SHOOT_HALF))) gui_osd_draw_raw_info();
2641       
2642            if ((conf.show_values==SHOW_ALWAYS && mode_photo) || ((mode_video || movie_status > 1)&& conf.show_values_in_video) || ((kbd_is_key_pressed(KEY_SHOOT_HALF) || (recreview_hold==1)) && (conf.show_values==SHOW_HALF)))
2643                   gui_osd_draw_values(1);
2644        else if  (shooting_get_common_focus_mode() && mode_photo && conf.show_values && !(conf.show_dof==DOF_SHOW_IN_DOF) )   
2645           gui_osd_draw_values(2);
2646            else if  (conf.show_values==SHOW_HALF)
2647                   gui_osd_draw_values(0);   
2648    }
2649
2650
2651     if ((recreview_hold==0) &&  (!kbd_is_key_pressed(KEY_SHOOT_HALF) &&  (  ((m&MODE_MASK) == MODE_REC) || (!((m&MODE_MASK) == MODE_REC) &&  !((conf.hide_osd == 1) || (conf.hide_osd == 3)) )) && !(((conf.hide_osd == 2) || (conf.hide_osd == 3))&& (shooting_get_prop(PROPCASE_DISPLAY_MODE) == 1))))   {
2652        gui_batt_draw_osd();
2653        gui_space_draw_osd();
2654    }
2655   
2656     if ((conf.show_clock) && (recreview_hold==0) &&  ((!kbd_is_key_pressed(KEY_SHOOT_HALF) &&  (  ((m&MODE_MASK) == MODE_REC) || (!((m&MODE_MASK) == MODE_REC) &&  !((conf.hide_osd == 1) || (conf.hide_osd == 3)) )) && !(((conf.hide_osd == 2) || (conf.hide_osd == 3))&& (shooting_get_prop(PROPCASE_DISPLAY_MODE) == 1)))|| (conf.clock_halfpress==0) )) {
2657        gui_osd_draw_clock(0,0,0);
2658            }
2659   
2660    else if ((conf.show_clock) && (recreview_hold==0) &&  kbd_is_key_pressed(KEY_SHOOT_HALF) && conf.clock_halfpress==1) {
2661        gui_osd_draw_seconds();
2662    }
2663 
2664      if ((conf.show_temp>0) && (recreview_hold==0) &&  ((!kbd_is_key_pressed(KEY_SHOOT_HALF) &&  (  ((m&MODE_MASK) == MODE_REC) || (!((m&MODE_MASK) == MODE_REC) &&  !((conf.hide_osd == 1) || (conf.hide_osd == 3)) )) && !(((conf.hide_osd == 2) || (conf.hide_osd == 3))&& (shooting_get_prop(PROPCASE_DISPLAY_MODE) == 1)) )|| (conf.clock_halfpress==0) )) {
2665        gui_osd_draw_temp();
2666      }
2667 if (conf.show_movie_time > 0 && (mode_video || movie_status > 1))
2668 {
2669 gui_osd_draw_movie_time_left();
2670}
2671 
2672 if ((conf.fast_ev) && (recreview_hold==0) && ((mode_get()&MODE_SHOOTING_MASK) != MODE_VIDEO_STD) && ((!kbd_is_key_pressed(KEY_SHOOT_HALF) &&  (  ((m&MODE_MASK) == MODE_REC) || (!((m&MODE_MASK) == MODE_REC) &&  !((conf.hide_osd == 1) || (conf.hide_osd == 3)) )) && !(((conf.hide_osd == 2) || (conf.hide_osd == 3))&& (shooting_get_prop(PROPCASE_DISPLAY_MODE) == 1))) )) {
2673       gui_osd_draw_ev();
2674 }
2675#if CAM_DRAW_EXPOSITION
2676    if (gui_mode==GUI_MODE_NONE && kbd_is_key_pressed(KEY_SHOOT_HALF) && ((m&MODE_MASK)==MODE_REC) && ((m&MODE_SHOOTING_MASK))!=MODE_VIDEO_STD && (m&MODE_SHOOTING_MASK)!=MODE_VIDEO_COMPACT) {
2677     strcpy(osd_buf,shooting_get_tv_str());
2678     strcat(osd_buf,"\"  F");
2679     strcat(osd_buf,shooting_get_av_str());
2680     draw_txt_string(22-strlen(osd_buf)/2, 14, osd_buf, conf.osd_color);
2681    }
2682#endif
2683
2684#if CAM_EV_IN_VIDEO
2685    if (movie_status==VIDEO_RECORD_IN_PROGRESS) gui_osd_draw_ev_video(get_ev_video_avail());
2686#endif
2687
2688#ifdef OPT_DEBUGGING
2689    if (debug_vals_show) {
2690//        long v=get_file_counter();
2691//      sprintf(osd_buf, "1:%03d-%04d  ", (v>>18)&0x3FF, (v>>4)&0x3FFF);
2692//      sprintf(osd_buf, "1:%d, %08X  ", xxxx, eeee);
2693/*
2694extern long physw_status[3];
2695        sprintf(osd_buf, "1:%8x  ", physw_status[0]);
2696        draw_txt_string(28, 10, osd_buf, conf.osd_color);
2697
2698        sprintf(osd_buf, "2:%8x  ", physw_status[1]);
2699        draw_txt_string(28, 11, osd_buf, conf.osd_color);
2700
2701        sprintf(osd_buf, "3:%8x  ", physw_status[2]);
2702        draw_txt_string(28, 12, osd_buf, conf.osd_color);
2703
2704        //      sprintf(osd_buf, "4:%8x  ", vid_get_viewport_fb_d());
2705*/
2706        sprintf(osd_buf, "u:%8x  ", get_usb_power(1));
2707        draw_txt_string(28,  9, osd_buf, conf.osd_color);
2708
2709        sprintf(osd_buf, "1:%8x  ", (void*) (*(int*)conf.mem_view_addr_init));
2710        draw_txt_string(28, 10, osd_buf, conf.osd_color);
2711
2712extern volatile long focus_busy;
2713        sprintf(osd_buf, "f:%8x  ", focus_busy);
2714        draw_txt_string(28, 11, osd_buf, conf.osd_color);
2715
2716extern volatile long zoom_busy;
2717        sprintf(osd_buf, "z:%8x  ", zoom_busy);
2718        draw_txt_string(28, 12, osd_buf, conf.osd_color);
2719
2720// some cameras missing zoom_status
2721#if 0
2722        sprintf(osd_buf, "t:%8x  ", zoom_status);
2723        draw_txt_string(28, 13, osd_buf, conf.osd_color);
2724#endif
2725
2726    }
2727
2728
2729   {
2730        static char sbuf[100];
2731    int r,i, p, len;
2732    if (conf.debug_display == DEBUG_DISPLAY_PROPS){
2733
2734        for (i=0;i<10;i++){
2735            r = 0;
2736            p = debug_propcase_page*10+i;
2737            get_property_case(p, &r, 4);
2738            sprintf(sbuf, "%3d: %d              ", p, r);sbuf[20]=0;
2739            draw_string(64,16+16*i,sbuf, conf.osd_color);
2740        }
2741    }
2742
2743    if (conf.debug_display == DEBUG_DISPLAY_PARAMS){
2744        extern long* FlashParamsTable[];
2745        char s[30];
2746        int count;
2747
2748        for (i=0;i<10;i++){
2749            r = 0;
2750            p = debug_propcase_page*10+i;
2751            if (p>=get_flash_params_count())  sprintf(sbuf, "%3d: This parameter does not exists", p);
2752            else   {
2753             len=FlashParamsTable[p][1]>>16;
2754             if ((len==1)||(len==2)||(len==4)){
2755              get_parameter_data(p, &r, len);
2756              sprintf(sbuf, "%3d: %30d :%2d ", p, r,len);
2757              }
2758             else {
2759              if (len>=sizeof(s)) count=sizeof(s)-1; else count=len;
2760              get_parameter_data(p, &s, count);
2761              s[count]=0;
2762              sprintf(sbuf, "%3d: %30s :%2d ", p, s,len);
2763             }
2764            }
2765            draw_string(16,16+16*i,sbuf, conf.osd_color);
2766        }
2767    }
2768   }
2769
2770    if(conf.debug_display == DEBUG_DISPLAY_TASKS) {
2771        gui_debug_draw_tasklist();
2772    }
2773#endif
2774    if (ubasic_error){
2775        const char *msg;
2776        if (ubasic_error >= UBASIC_E_ENDMARK) {
2777            msg = ubasic_errstrings[UBASIC_E_UNKNOWN_ERROR];
2778        } else {
2779            msg = ubasic_errstrings[ubasic_error];
2780        }
2781        sprintf(osd_buf, "uBASIC:%d %s ", ubasic_linenumber(), msg);
2782        draw_txt_string(0, 0, osd_buf, MAKE_COLOR(COLOR_RED, COLOR_YELLOW));
2783    }
2784}
2785
2786#ifndef OPTIONS_AUTOSAVE
2787//-------------------------------------------------------------------
2788void gui_menuproc_save(int arg)
2789{
2790    conf_save();
2791}
2792#endif
2793
2794//-------------------------------------------------------------------
2795static void gui_menuproc_reset_selected(unsigned int btn) {
2796    if (btn==MBOX_BTN_YES)
2797        conf_load_defaults();
2798}
2799
2800void gui_menuproc_reset(int arg)
2801{
2802    gui_mbox_init(LANG_MSG_RESET_OPTIONS_TITLE,
2803                  LANG_MSG_RESET_OPTIONS_TEXT,
2804                  MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER|MBOX_BTN_YES_NO|MBOX_DEF_BTN2, gui_menuproc_reset_selected);
2805}
2806
2807//-------------------------------------------------------------------
2808void gui_draw_palette(int arg) {
2809    draw_restore();
2810    gui_palette_init(PALETTE_MODE_DEFAULT, 0x00, NULL);
2811    gui_mode = GUI_MODE_PALETTE;
2812}
2813
2814//-------------------------------------------------------------------
2815void gui_show_build_info(int arg) {
2816    static char buf[192];
2817    static char comp[64];
2818
2819#ifdef __GNUC__
2820# ifndef __GNUC_PATCHLEVEL__
2821# define __GNUC_PATCHLEVEL 0
2822# endif
2823    sprintf(comp, "GCC %d.%d.%d", __GNUC__ ,__GNUC_MINOR__,__GNUC_PATCHLEVEL__ );
2824#else
2825    sprintf(comp, "UNKNOWN" );
2826#endif
2827    sprintf(buf, lang_str(LANG_MSG_BUILD_INFO_TEXT), HDK_VERSION, BUILD_NUMBER, __DATE__, __TIME__, PLATFORM, PLATFORMSUB, comp);
2828gui_mbox_init(LANG_MSG_BUILD_INFO_TITLE, (int)buf, MBOX_FUNC_RESTORE|MBOX_TEXT_LEFT, NULL);
2829}
2830
2831//-------------------------------------------------------------------
2832void gui_show_memory_info(int arg) {
2833    static char buf[64];
2834    int size, l_size, d;
2835    char* ptr;
2836
2837    size = 16;
2838    while (1) {
2839        ptr= malloc(size);
2840        if (ptr) {
2841            free(ptr);
2842            size <<= 1;
2843        } else
2844            break;
2845    }
2846
2847    l_size = size;
2848    size >>= 1;
2849    d=1024;
2850    while (d) {
2851        ptr = malloc(size);
2852        if (ptr) {
2853            free(ptr);
2854            d = l_size-size;
2855            if (d<0) d=-d;
2856            l_size = size;
2857            size += d>>1;
2858        } else {
2859            d = size-l_size;
2860            if (d<0) d=-d;
2861            l_size = size;
2862            size -= d>>1;
2863        }
2864       
2865    }
2866   
2867    sprintf(buf, lang_str(LANG_MSG_MEMORY_INFO_TEXT), size-1,MEMISOSIZE,&_start,&_end);
2868    gui_mbox_init(LANG_MSG_MEMORY_INFO_TITLE, (int)buf, MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL);
2869}
2870
2871//-------------------------------------------------------------------
2872#ifdef OPT_GAME_REVERSI
2873void gui_draw_reversi(int arg) {
2874    if ((mode_get()&MODE_MASK) != MODE_PLAY) {
2875        gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE,
2876                      MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL);
2877        return;
2878    }
2879    gui_mode = GUI_MODE_REVERSI;
2880    gui_reversi_init();
2881}
2882#endif
2883
2884//-------------------------------------------------------------------
2885#ifdef OPT_GAME_SOKOBAN
2886void gui_draw_sokoban(int arg) {
2887    if ((mode_get()&MODE_MASK) != MODE_PLAY) {
2888        gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE,
2889                      MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL);
2890        return;
2891    }
2892    if ( gui_sokoban_init() )
2893        gui_mode = GUI_MODE_SOKOBAN;
2894}
2895#endif
2896//-------------------------------------------------------------------
2897#ifdef OPT_GAME_CONNECT4
2898void gui_draw_4wins(int arg) {
2899    if ((mode_get()&MODE_MASK) != MODE_PLAY) {
2900        gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE,
2901                      MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL);
2902        return;
2903    }
2904    if ( gui_4wins_init() )
2905        gui_mode = GUI_MODE_4WINS;
2906}
2907#endif
2908//-------------------------------------------------------------------
2909#ifdef OPT_GAME_MASTERMIND
2910void gui_draw_mastermind(int arg) {
2911    if ((mode_get()&MODE_MASK) != MODE_PLAY) {
2912        gui_mbox_init(LANG_MSG_INFO_TITLE, LANG_MSG_SWITCH_TO_PLAY_MODE,
2913                      MBOX_FUNC_RESTORE|MBOX_TEXT_CENTER, NULL);
2914        return;
2915    }
2916    if ( gui_mastermind_init() )
2917        gui_mode = GUI_MODE_MASTERMIND;
2918}
2919#endif
2920//-------------------------------------------------------------------
2921#ifdef OPT_DEBUGGING
2922void gui_draw_debug(int arg) {
2923//    gui_debug_init(0x2510);
2924//    gui_debug_init(0x127E0);
2925//    gui_debug_init(0x7F5B8);
2926//    gui_debug_init(malloc(16));
2927    gui_debug_init((void*)conf.mem_view_addr_init);
2928}
2929#endif
2930//-------------------------------------------------------------------
2931#ifdef OPT_DEBUGGING
2932void gui_draw_bench(int arg) {
2933    gui_mode = GUI_MODE_BENCH;
2934    gui_bench_init();
2935}
2936#endif
2937//-------------------------------------------------------------------
2938
2939void gui_draw_splash(char* logo, int logo_size) {
2940    coord w, h, x, y;
2941    static const char *text[] = {
2942        "CHDK Firmware '" HDK_VERSION " " BUILD_NUMBER "'" ,
2943        "Build: " __DATE__ " " __TIME__ ,
2944        "Camera: " PLATFORM " - " PLATFORMSUB };
2945    int i, l;
2946    color cl = MAKE_COLOR(COLOR_RED, COLOR_WHITE);
2947
2948    gui_splash_mode = (mode_get()&MODE_MASK);
2949   
2950    h=sizeof(text)/sizeof(text[0])*FONT_HEIGHT+8;
2951    w=0;
2952    for (i=0; i<sizeof(text)/sizeof(text[0]); ++i) {
2953        l=strlen(text[i]);
2954        if (l>w) w=l;
2955    }
2956    w=w*FONT_WIDTH+10;
2957
2958    x = (screen_width-w)>>1; y = ((screen_height-h)>>1) + 20;
2959    draw_filled_round_rect(x, y, x+w, y+h, MAKE_COLOR(COLOR_RED, COLOR_RED));
2960    for (i=0; i<sizeof(text)/sizeof(text[0]); ++i) {
2961        draw_string(x+((w-strlen(text[i])*FONT_WIDTH)>>1), y+i*FONT_HEIGHT+4, text[i], cl);
2962    }
2963    if(logo){
2964      int pos;
2965      int mx=0;
2966      int my=0;
2967      int offset_x = (screen_width-150)>>1;
2968      int offset_y = ((screen_height-84)>>1) - 42;
2969      const color color_lookup[8] = {0xFF, 0x2E, 0x22, 0x3D, 0x1F,  0x21, 0x00, 0x11};
2970   
2971      for(pos=0; pos<logo_size; pos++){
2972          char data = logo[pos];
2973          color c = color_lookup[(data>>5) & 0x07];
2974          for(i=0; i<(data&0x1F)+1; i++){
2975              if (c!=0x00){
2976                  draw_pixel(offset_x+mx,offset_y+my,c);
2977              }
2978              if (mx==149){
2979                  mx=0;
2980                  my++;
2981              }else{
2982                  mx++;
2983              }     
2984          }
2985      }
2986    }
2987}
2988
2989//-------------------------------------------------------------------
2990void gui_draw_fselect(int arg) {
2991    gui_fselect_init(LANG_STR_FILE_BROWSER, "A", NULL);
2992}
2993
2994//-------------------------------------------------------------------
2995static void gui_load_script_selected(const char *fn) {
2996    if (fn)
2997        script_load(fn, 1);
2998}
2999void gui_load_script(int arg) {
3000    DIR   *d;
3001    char  *path="A/CHDK/SCRIPTS";
3002
3003    // if exists "A/CHDK/SCRIPTS" go into
3004    d=opendir(path);
3005    if (d) {
3006        closedir(d);
3007    } else {
3008        path="A";
3009    }
3010
3011    gui_fselect_init(LANG_STR_SELECT_SCRIPT_FILE, path, gui_load_script_selected);
3012}
3013
3014void gui_load_script_default(int arg) {
3015    script_load(conf.script_file, 0);
3016    if (conf.script_param_save) {
3017        save_params_values(1);
3018    }
3019}
3020
3021
3022//-------------------------------------------------------------------
3023static void gui_grid_lines_load_selected(const char *fn) {
3024    if (fn)
3025        grid_lines_load(fn);
3026}
3027void gui_grid_lines_load(int arg) {
3028    DIR   *d;
3029    char  *path="A/CHDK/GRIDS";
3030
3031    // if exists "A/CHDK/GRIDS" go into
3032    d=opendir(path);
3033    if (d) {
3034        closedir(d);
3035    } else {
3036        path="A";
3037    }
3038
3039    gui_fselect_init(LANG_STR_SELECT_GRID_FILE, path, gui_grid_lines_load_selected);
3040}
3041
3042//-------------------------------------------------------------------
3043void gui_draw_osd_le(int arg) {
3044    gui_mode = GUI_MODE_OSD;
3045    gui_osd_init();
3046}
3047
3048//-------------------------------------------------------------------
3049#ifdef OPT_TEXTREADER
3050static void gui_draw_read_selected(const char *fn) {
3051    if (fn) {
3052        if (!rbf_load(conf.reader_rbf_file))
3053            rbf_load_from_8x16(current_font);
3054        rbf_set_codepage(conf.reader_codepage);
3055        gui_mode = GUI_MODE_READ;
3056        gui_read_init(fn);
3057    }
3058}
3059void gui_draw_read(int arg) {
3060    DIR   *d;
3061    char  *path="A/CHDK/BOOKS";
3062
3063    // if exists "A/CHDK/BOOKS" go into
3064    d=opendir(path);
3065    if (d) {
3066        closedir(d);
3067    } else {
3068        path="A";
3069    }
3070    gui_fselect_init(LANG_STR_SELECT_TEXT_FILE, path, gui_draw_read_selected);
3071}
3072
3073//-------------------------------------------------------------------
3074void gui_draw_read_last(int arg) {
3075    int fd;
3076   
3077    fd = open(conf.reader_file, O_RDONLY, 0777);
3078    if (fd >= 0) {
3079        close(fd);
3080        gui_draw_read_selected(conf.reader_file);
3081    } else {
3082        gui_draw_read(arg);
3083    }
3084}
3085#endif
3086
3087//-------------------------------------------------------------------
3088void gui_menuproc_mkbootdisk(int arg) {
3089    mark_filesystem_bootable();
3090}
3091
3092void gui_menuproc_edge_free(int arg) {
3093    free_memory_edge_overlay();
3094}
3095
3096void gui_menuproc_edge_save(int arg) {
3097    save_edge_overlay();
3098}
3099
3100void gui_menuproc_edge_load(int arg) {
3101    DIR   *d;
3102    char  *path = EDGE_SAVE_DIR;
3103    const char* fn;
3104
3105    // if exists, go into
3106    d=opendir(path);
3107    if (d) {
3108        closedir(d);
3109    } else {
3110        path="A";
3111    }
3112
3113    gui_fselect_init(LANG_MENU_EDGE_LOAD, path, gui_load_edge_selected);
3114}
3115
3116//-------------------------------------------------------------------
3117#ifdef OPT_CALENDAR
3118void gui_draw_calendar(int arg) {
3119    gui_mode = GUI_MODE_CALENDAR;
3120    gui_calendar_init();
3121}
3122#endif
3123//-------------------------------------------------------------------
3124static void gui_draw_rbf_selected(const char *fn) {
3125    if (fn) {
3126        strcpy(conf.reader_rbf_file, fn);
3127    }
3128}
3129#ifdef OPT_TEXTREADER
3130void gui_draw_load_rbf(int arg) {
3131    DIR   *d;
3132    char  *path="A/CHDK/FONTS";
3133
3134    // if exists "A/CHDK/FONTS" go into
3135    d=opendir(path);
3136    if (d) {
3137        closedir(d);
3138    } else {
3139        path="A";
3140    }
3141
3142    gui_fselect_init(LANG_STR_SELECT_FONT_FILE, path, gui_draw_rbf_selected);
3143}
3144#endif
3145//-------------------------------------------------------------------
3146static void gui_draw_menu_rbf_selected(const char *fn) {
3147    if (fn) {
3148        strcpy(conf.menu_rbf_file, fn);
3149        if (!rbf_load(conf.menu_rbf_file))
3150            rbf_load_from_8x16(current_font);
3151        rbf_set_codepage(FONT_CP_WIN);
3152        gui_menu_init(NULL);
3153    }
3154}
3155void gui_draw_load_menu_rbf(int arg) {
3156    DIR   *d;
3157    char  *path="A/CHDK/FONTS";
3158
3159    // if exists "A/CHDK/FONTS" go into
3160    d=opendir(path);
3161    if (d) {
3162        closedir(d);
3163    } else {
3164        path="A";
3165    }
3166
3167    gui_fselect_init(LANG_STR_SELECT_FONT_FILE, path, gui_draw_menu_rbf_selected);
3168}
3169
3170//-------------------------------------------------------------------
3171static void gui_draw_symbol_rbf_selected(const char *fn) {
3172    if (fn) {
3173        strcpy(conf.menu_symbol_rbf_file, fn);
3174        if(!rbf_load_symbol(conf.menu_symbol_rbf_file)) conf.menu_symbol_enable=0;              //AKA
3175        gui_menu_init(NULL);
3176    }
3177}
3178void gui_draw_load_symbol_rbf(int arg) {
3179    DIR   *d;
3180    char  *path="A/CHDK/SYMBOLS";
3181
3182    // if exists "A/CHDK/FONTS" go into
3183    d=opendir(path);
3184    if (d) {
3185        closedir(d);
3186    } else {
3187        path="A";
3188    }
3189
3190    gui_fselect_init(LANG_STR_SELECT_SYMBOL_FILE, path, gui_draw_symbol_rbf_selected);
3191}
3192
3193//-------------------------------------------------------------------
3194static void gui_draw_lang_selected(const char *fn) {
3195    if (fn) {
3196        strcpy(conf.lang_file, fn);
3197        lang_load_from_file(conf.lang_file);
3198        gui_menu_init(NULL);
3199    }
3200}
3201void gui_draw_load_lang(int arg) {
3202    DIR   *d;
3203    char  *path="A/CHDK/LANG";
3204
3205    // if exists "A/CHDK/LANG" go into
3206    d=opendir(path);
3207    if (d) {
3208        closedir(d);
3209    } else {
3210        path="A";
3211    }
3212
3213    gui_fselect_init(LANG_STR_SELECT_LANG_FILE, path, gui_draw_lang_selected);
3214}
3215
3216int find_mnu(CMenu *curr_menu, int mnu, int count)
3217{
3218        int gui_menu_curr_item;
3219
3220        gui_menu_curr_item = 0;
3221        while(curr_menu->menu[gui_menu_curr_item].text) {
3222                if (curr_menu->menu[gui_menu_curr_item].text == mnu){
3223                        user_submenu_items[count] = curr_menu->menu[gui_menu_curr_item];
3224                        return 1;
3225                }
3226                if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK) == MENUITEM_SUBMENU)
3227                        if (curr_menu->menu[gui_menu_curr_item].text != LANG_MENU_USER_MENU)
3228                                if (find_mnu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), mnu, count)) return 1;
3229                gui_menu_curr_item++;
3230        }
3231        return 0;
3232}
3233
3234void user_menu_save() {
3235    int x;
3236        for (x=0; x<USER_MENU_ITEMS; x++) {
3237                /*
3238                 * First entry in user_submenu_items is reserved for the "Main Menu"
3239                 * conf.user_menu_vars only traks/saves the real user entries.
3240                 */
3241                conf.user_menu_vars[x] = user_submenu_items[x+1].text;
3242        }
3243}
3244 
3245void user_menu_restore() {
3246     int x;
3247        for (x=0; x<USER_MENU_ITEMS; x++) {
3248                /*
3249                 * First entry in user_submenu_items is reserved for the "Main Menu"
3250                 * conf.user_menu_vars only traks/saves the real user entries.
3251                 */
3252                find_mnu(&root_menu, conf.user_menu_vars[x], x+1);
3253        }
3254}
3255
3256#ifdef OPT_DEBUGGING
3257
3258void gui_compare_props(int arg)
3259{
3260        #define NUM_PROPS 512
3261        static int initialized = 0;
3262        static int props[NUM_PROPS] = { };
3263        char buf[64];
3264        int i;
3265        int p;
3266        int c;
3267
3268
3269        if( initialized )
3270        { // we have previous data set! do a comparison
3271                c = 0;
3272                for( i = 0; i < NUM_PROPS; ++i )
3273                {
3274                        p = shooting_get_prop(i);
3275                        if( props[i] != p )
3276                        {
3277                                ++c;
3278                                sprintf(buf,"%4d is %8d was %8d",i,p,props[i]);
3279                                draw_string(16,16*c,buf,MAKE_COLOR(COLOR_BLACK,COLOR_YELLOW));
3280                        }
3281                        props[i] = p;
3282                        if( c == 12 )
3283                        {
3284                                ++c;
3285                                sprintf(buf,"%s","Waiting 15 Seconds");
3286                                draw_string(16,16*c,buf,MAKE_COLOR(COLOR_BLACK,COLOR_YELLOW));
3287                                msleep(15000);
3288                                c = 0;
3289                        }
3290                }
3291                ++c;
3292                sprintf(buf,"%s","Press <ALT> to leave");
3293                draw_string(16,16*c,buf,MAKE_COLOR(COLOR_BLACK,COLOR_YELLOW));
3294        }
3295        else
3296        {
3297        // no previous data was set so we save the data initially
3298                for( i = 0; i < NUM_PROPS; ++i )
3299                {
3300                        props[i] = shooting_get_prop(i);
3301                }
3302        }
3303        initialized = 1;
3304}
3305
3306#endif
Note: See TracBrowser for help on using the repository browser.