1 /* options.c: options dialog boxes
2    Copyright (c) 2001-2013 Philip Kendall, Marek Januszewski, Stuart Brady
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2 of the License, or
7    (at your option) any later version.
8 
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License along
15    with this program; if not, write to the Free Software Foundation, Inc.,
16    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 
18    Author contact information:
19 
20    E-mail: philip-fuse@shadowmagic.org.uk
21 
22 */
23 
24 /* This file is autogenerated from options.dat by options.pl.
25    Do not edit unless you know what you're doing! */
26 
27 #include <config.h>
28 
29 #ifdef UI_WIN32                /* Use this file if we're using WIN32 */
30 
31 #include <libspectrum.h>
32 
33 #include "display.h"
34 #include "fuse.h"
35 #include "options.h"
36 #include "options_internals.h"
37 #include "periph.h"
38 #include "settings.h"
39 #include "ui/win32/win32internals.h"
40 #include "utils.h"
41 
42 static int
option_enumerate_combo(const char * const * options,char * value,int count,int def)43 option_enumerate_combo( const char * const *options, char *value, int count,
44                         int def ) {
45   int i;
46   if( value != NULL ) {
47     for( i = 0; i < count; i++) {
48       if( !strcmp( value, options[ i ] ) )
49         return i;
50     }
51   }
52   return def;
53 }
54 
55 static void
menu_options_general_init(HWND hwndDlg)56 menu_options_general_init( HWND hwndDlg )
57 {
58   char buffer[80];
59   int i;
60 
61   i = 0;
62   buffer[0] = '\0';
63   if( buffer[i] ) {};          /* Shut gcc up */
64 
65   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_EMULATION_SPEED, EM_LIMITTEXT,
66                       5, 0 );
67   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
68   snprintf( buffer, 80, "%d", settings_current.emulation_speed );
69   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_EMULATION_SPEED, WM_SETTEXT,
70                       0, (LPARAM) buffer );
71 
72   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_FRAME_RATE, EM_LIMITTEXT,
73                       1, 0 );
74   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
75   snprintf( buffer, 80, "%d", settings_current.frame_rate );
76   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_FRAME_RATE, WM_SETTEXT,
77                       0, (LPARAM) buffer );
78 
79   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_ISSUE2, BM_SETCHECK,
80     settings_current.issue2 ? BST_CHECKED : BST_UNCHECKED, 0 );
81 
82   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_RECREATED_SPECTRUM, BM_SETCHECK,
83     settings_current.recreated_spectrum ? BST_CHECKED : BST_UNCHECKED, 0 );
84 
85   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_KEYBOARD_ARROWS_SHIFTED, BM_SETCHECK,
86     settings_current.keyboard_arrows_shifted ? BST_CHECKED : BST_UNCHECKED, 0 );
87 
88   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_WRITABLE_ROMS, BM_SETCHECK,
89     settings_current.writable_roms ? BST_CHECKED : BST_UNCHECKED, 0 );
90 
91   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_LATE_TIMINGS, BM_SETCHECK,
92     settings_current.late_timings ? BST_CHECKED : BST_UNCHECKED, 0 );
93 
94   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_Z80_IS_CMOS, BM_SETCHECK,
95     settings_current.z80_is_cmos ? BST_CHECKED : BST_UNCHECKED, 0 );
96 
97   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_RS232_HANDSHAKE, BM_SETCHECK,
98     settings_current.rs232_handshake ? BST_CHECKED : BST_UNCHECKED, 0 );
99 
100   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_BW_TV, BM_SETCHECK,
101     settings_current.bw_tv ? BST_CHECKED : BST_UNCHECKED, 0 );
102 
103   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_PAL_TV2X, BM_SETCHECK,
104     settings_current.pal_tv2x ? BST_CHECKED : BST_UNCHECKED, 0 );
105 
106   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_STATUSBAR, BM_SETCHECK,
107     settings_current.statusbar ? BST_CHECKED : BST_UNCHECKED, 0 );
108 
109   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_JOY_PROMPT, BM_SETCHECK,
110     settings_current.joy_prompt ? BST_CHECKED : BST_UNCHECKED, 0 );
111 
112   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_CONFIRM_ACTIONS, BM_SETCHECK,
113     settings_current.confirm_actions ? BST_CHECKED : BST_UNCHECKED, 0 );
114 
115   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_AUTOSAVE_SETTINGS, BM_SETCHECK,
116     settings_current.autosave_settings ? BST_CHECKED : BST_UNCHECKED, 0 );
117 
118 }
119 
120 static void
menu_options_general_done(HWND hwndDlg)121 menu_options_general_done( HWND hwndDlg )
122 {
123   char buffer[80];
124 
125   buffer[0] = '\0';
126   if( buffer[0] ) {};          /* Shut gcc up */
127 
128   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
129   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_EMULATION_SPEED, WM_GETTEXT,
130                       80, (LPARAM) buffer );
131   settings_current.emulation_speed = atoi( buffer );
132 
133   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
134   SendDlgItemMessage( hwndDlg, IDC_OPT_GENERAL_FRAME_RATE, WM_GETTEXT,
135                       80, (LPARAM) buffer );
136   settings_current.frame_rate = atoi( buffer );
137 
138   settings_current.issue2 =
139     IsDlgButtonChecked( hwndDlg, IDC_OPT_GENERAL_ISSUE2 );
140 
141   settings_current.recreated_spectrum =
142     IsDlgButtonChecked( hwndDlg, IDC_OPT_GENERAL_RECREATED_SPECTRUM );
143 
144   settings_current.keyboard_arrows_shifted =
145     IsDlgButtonChecked( hwndDlg, IDC_OPT_GENERAL_KEYBOARD_ARROWS_SHIFTED );
146 
147   settings_current.writable_roms =
148     IsDlgButtonChecked( hwndDlg, IDC_OPT_GENERAL_WRITABLE_ROMS );
149 
150   settings_current.late_timings =
151     IsDlgButtonChecked( hwndDlg, IDC_OPT_GENERAL_LATE_TIMINGS );
152 
153   settings_current.z80_is_cmos =
154     IsDlgButtonChecked( hwndDlg, IDC_OPT_GENERAL_Z80_IS_CMOS );
155 
156   settings_current.rs232_handshake =
157     IsDlgButtonChecked( hwndDlg, IDC_OPT_GENERAL_RS232_HANDSHAKE );
158 
159   settings_current.bw_tv =
160     IsDlgButtonChecked( hwndDlg, IDC_OPT_GENERAL_BW_TV );
161 
162   settings_current.pal_tv2x =
163     IsDlgButtonChecked( hwndDlg, IDC_OPT_GENERAL_PAL_TV2X );
164 
165   settings_current.statusbar =
166     IsDlgButtonChecked( hwndDlg, IDC_OPT_GENERAL_STATUSBAR );
167 
168   settings_current.joy_prompt =
169     IsDlgButtonChecked( hwndDlg, IDC_OPT_GENERAL_JOY_PROMPT );
170 
171   settings_current.confirm_actions =
172     IsDlgButtonChecked( hwndDlg, IDC_OPT_GENERAL_CONFIRM_ACTIONS );
173 
174   settings_current.autosave_settings =
175     IsDlgButtonChecked( hwndDlg, IDC_OPT_GENERAL_AUTOSAVE_SETTINGS );
176 
177   win32statusbar_set_visibility( settings_current.statusbar );
178   display_refresh_all();
179 
180   EndDialog( hwndDlg, 0 );
181 }
182 
183 static BOOL CALLBACK
menu_options_general_proc(HWND hwndDlg,UINT msg,WPARAM wParam GCC_UNUSED,LPARAM lParam GCC_UNUSED)184 menu_options_general_proc( HWND hwndDlg, UINT msg, WPARAM wParam GCC_UNUSED,
185                               LPARAM lParam GCC_UNUSED )
186 {
187   switch( msg )
188   {
189     case WM_INITDIALOG:
190     {
191       /* FIXME: save the handle returned by LoadIcon() in win32ui.c */
192       SendMessage( hwndDlg, WM_SETICON, ICON_SMALL,
193                    (LPARAM)LoadIcon( fuse_hInstance, "win32_icon" ) );
194 
195       /* initialize the controls with current settings */
196       menu_options_general_init( hwndDlg );
197 
198       return TRUE;
199     }
200 
201     case WM_COMMAND:
202       switch( LOWORD( wParam ) )
203       {
204         case IDOK:
205           /* Read the controls and apply the settings */
206           menu_options_general_done( hwndDlg );
207           return 0;
208 
209         case IDCANCEL:
210           EndDialog( hwndDlg, 0 );
211           return 0;
212       }
213       break;
214 
215     case WM_CLOSE:
216       EndDialog( hwndDlg, 0 );
217       return 0;
218   }
219 
220   return FALSE;
221 }
222 
223 void
menu_options_general(int action GCC_UNUSED)224 menu_options_general( int action GCC_UNUSED )
225 {
226   fuse_emulation_pause();
227 
228   DialogBox( fuse_hInstance, MAKEINTRESOURCE( IDD_OPT_GENERAL ),
229              fuse_hWnd, (DLGPROC) menu_options_general_proc );
230 
231   fuse_emulation_unpause();
232 }
233 
234 
235 static const char * const media_phantom_typist_mode_combo[] = {
236   "Auto",
237   "Keyword",
238   "Keystroke",
239   "Menu",
240   "Plus 2A",
241   "Plus 3",
242 };
243 
244 static const int media_phantom_typist_mode_combo_count = 6;
245 
246 int
option_enumerate_media_phantom_typist_mode(void)247 option_enumerate_media_phantom_typist_mode( void ) {
248   return option_enumerate_combo( media_phantom_typist_mode_combo,
249                                  settings_current.phantom_typist_mode,
250                                  media_phantom_typist_mode_combo_count,
251                                  0 );
252 }
253 
254 static void
menu_options_media_init(HWND hwndDlg)255 menu_options_media_init( HWND hwndDlg )
256 {
257   char buffer[80];
258   int i;
259 
260   i = 0;
261   buffer[0] = '\0';
262   if( buffer[i] ) {};          /* Shut gcc up */
263 
264   SendDlgItemMessage( hwndDlg, IDC_OPT_MEDIA_AUTO_LOAD, BM_SETCHECK,
265     settings_current.auto_load ? BST_CHECKED : BST_UNCHECKED, 0 );
266 
267   for( i = 0; i < media_phantom_typist_mode_combo_count; i++ ) {
268     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
269     SendDlgItemMessage( hwndDlg, IDC_OPT_MEDIA_PHANTOM_TYPIST_MODE, CB_ADDSTRING,
270                         0, (LPARAM) media_phantom_typist_mode_combo[i] );
271   }
272   SendDlgItemMessage( hwndDlg, IDC_OPT_MEDIA_PHANTOM_TYPIST_MODE, CB_SETCURSEL,
273                       (LPARAM) 0, 0 );
274   if( settings_current.phantom_typist_mode != NULL ) {
275     for( i = 0; i < media_phantom_typist_mode_combo_count; i++ ) {
276       if( !strcmp( settings_current.phantom_typist_mode,
277                    media_phantom_typist_mode_combo[i] ) ) {
278         SendDlgItemMessage( hwndDlg, IDC_OPT_MEDIA_PHANTOM_TYPIST_MODE,
279                             CB_SETCURSEL, i, 0 );
280       }
281     }
282   }
283   SendDlgItemMessage( hwndDlg, IDC_OPT_MEDIA_DETECT_LOADER, BM_SETCHECK,
284     settings_current.detect_loader ? BST_CHECKED : BST_UNCHECKED, 0 );
285 
286   SendDlgItemMessage( hwndDlg, IDC_OPT_MEDIA_FASTLOAD, BM_SETCHECK,
287     settings_current.fastload ? BST_CHECKED : BST_UNCHECKED, 0 );
288 
289   SendDlgItemMessage( hwndDlg, IDC_OPT_MEDIA_TAPE_TRAPS, BM_SETCHECK,
290     settings_current.tape_traps ? BST_CHECKED : BST_UNCHECKED, 0 );
291 
292   SendDlgItemMessage( hwndDlg, IDC_OPT_MEDIA_ACCELERATE_LOADER, BM_SETCHECK,
293     settings_current.accelerate_loader ? BST_CHECKED : BST_UNCHECKED, 0 );
294 
295   SendDlgItemMessage( hwndDlg, IDC_OPT_MEDIA_SLT_TRAPS, BM_SETCHECK,
296     settings_current.slt_traps ? BST_CHECKED : BST_UNCHECKED, 0 );
297 
298   SendDlgItemMessage( hwndDlg, IDC_OPT_MEDIA_MDR_LEN, EM_LIMITTEXT,
299                       3, 0 );
300   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
301   snprintf( buffer, 80, "%d", settings_current.mdr_len );
302   SendDlgItemMessage( hwndDlg, IDC_OPT_MEDIA_MDR_LEN, WM_SETTEXT,
303                       0, (LPARAM) buffer );
304 
305   SendDlgItemMessage( hwndDlg, IDC_OPT_MEDIA_MDR_RANDOM_LEN, BM_SETCHECK,
306     settings_current.mdr_random_len ? BST_CHECKED : BST_UNCHECKED, 0 );
307 
308 }
309 
310 static void
menu_options_media_done(HWND hwndDlg)311 menu_options_media_done( HWND hwndDlg )
312 {
313   char buffer[80];
314 
315   buffer[0] = '\0';
316   if( buffer[0] ) {};          /* Shut gcc up */
317 
318   settings_current.auto_load =
319     IsDlgButtonChecked( hwndDlg, IDC_OPT_MEDIA_AUTO_LOAD );
320 
321   libspectrum_free( settings_current.phantom_typist_mode );
322   settings_current.phantom_typist_mode =
323     utils_safe_strdup( media_phantom_typist_mode_combo[
324     SendDlgItemMessage( hwndDlg, IDC_OPT_MEDIA_PHANTOM_TYPIST_MODE, CB_GETCURSEL, 0, 0 ) ] );
325 
326   settings_current.detect_loader =
327     IsDlgButtonChecked( hwndDlg, IDC_OPT_MEDIA_DETECT_LOADER );
328 
329   settings_current.fastload =
330     IsDlgButtonChecked( hwndDlg, IDC_OPT_MEDIA_FASTLOAD );
331 
332   settings_current.tape_traps =
333     IsDlgButtonChecked( hwndDlg, IDC_OPT_MEDIA_TAPE_TRAPS );
334 
335   settings_current.accelerate_loader =
336     IsDlgButtonChecked( hwndDlg, IDC_OPT_MEDIA_ACCELERATE_LOADER );
337 
338   settings_current.slt_traps =
339     IsDlgButtonChecked( hwndDlg, IDC_OPT_MEDIA_SLT_TRAPS );
340 
341   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
342   SendDlgItemMessage( hwndDlg, IDC_OPT_MEDIA_MDR_LEN, WM_GETTEXT,
343                       80, (LPARAM) buffer );
344   settings_current.mdr_len = atoi( buffer );
345 
346   settings_current.mdr_random_len =
347     IsDlgButtonChecked( hwndDlg, IDC_OPT_MEDIA_MDR_RANDOM_LEN );
348 
349   win32statusbar_set_visibility( settings_current.statusbar );
350   display_refresh_all();
351 
352   EndDialog( hwndDlg, 0 );
353 }
354 
355 static BOOL CALLBACK
menu_options_media_proc(HWND hwndDlg,UINT msg,WPARAM wParam GCC_UNUSED,LPARAM lParam GCC_UNUSED)356 menu_options_media_proc( HWND hwndDlg, UINT msg, WPARAM wParam GCC_UNUSED,
357                               LPARAM lParam GCC_UNUSED )
358 {
359   switch( msg )
360   {
361     case WM_INITDIALOG:
362     {
363       /* FIXME: save the handle returned by LoadIcon() in win32ui.c */
364       SendMessage( hwndDlg, WM_SETICON, ICON_SMALL,
365                    (LPARAM)LoadIcon( fuse_hInstance, "win32_icon" ) );
366 
367       /* initialize the controls with current settings */
368       menu_options_media_init( hwndDlg );
369 
370       return TRUE;
371     }
372 
373     case WM_COMMAND:
374       switch( LOWORD( wParam ) )
375       {
376         case IDOK:
377           /* Read the controls and apply the settings */
378           menu_options_media_done( hwndDlg );
379           return 0;
380 
381         case IDCANCEL:
382           EndDialog( hwndDlg, 0 );
383           return 0;
384       }
385       break;
386 
387     case WM_CLOSE:
388       EndDialog( hwndDlg, 0 );
389       return 0;
390   }
391 
392   return FALSE;
393 }
394 
395 void
menu_options_media(int action GCC_UNUSED)396 menu_options_media( int action GCC_UNUSED )
397 {
398   fuse_emulation_pause();
399 
400   DialogBox( fuse_hInstance, MAKEINTRESOURCE( IDD_OPT_MEDIA ),
401              fuse_hWnd, (DLGPROC) menu_options_media_proc );
402 
403   fuse_emulation_unpause();
404 }
405 
406 static void
menu_options_peripherals_general_init(HWND hwndDlg)407 menu_options_peripherals_general_init( HWND hwndDlg )
408 {
409   char buffer[80];
410   int i;
411 
412   i = 0;
413   buffer[0] = '\0';
414   if( buffer[i] ) {};          /* Shut gcc up */
415 
416   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_JOY_KEMPSTON, BM_SETCHECK,
417     settings_current.joy_kempston ? BST_CHECKED : BST_UNCHECKED, 0 );
418 
419   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_KEMPSTON_MOUSE, BM_SETCHECK,
420     settings_current.kempston_mouse ? BST_CHECKED : BST_UNCHECKED, 0 );
421 
422   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_MOUSE_SWAP_BUTTONS, BM_SETCHECK,
423     settings_current.mouse_swap_buttons ? BST_CHECKED : BST_UNCHECKED, 0 );
424 
425   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_FULLER, BM_SETCHECK,
426     settings_current.fuller ? BST_CHECKED : BST_UNCHECKED, 0 );
427 
428   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_MELODIK, BM_SETCHECK,
429     settings_current.melodik ? BST_CHECKED : BST_UNCHECKED, 0 );
430 
431   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_INTERFACE1, BM_SETCHECK,
432     settings_current.interface1 ? BST_CHECKED : BST_UNCHECKED, 0 );
433 
434   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_INTERFACE2, BM_SETCHECK,
435     settings_current.interface2 ? BST_CHECKED : BST_UNCHECKED, 0 );
436 
437   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_MULTIFACE1, BM_SETCHECK,
438     settings_current.multiface1 ? BST_CHECKED : BST_UNCHECKED, 0 );
439 
440   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_MULTIFACE128, BM_SETCHECK,
441     settings_current.multiface128 ? BST_CHECKED : BST_UNCHECKED, 0 );
442 
443   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_MULTIFACE3, BM_SETCHECK,
444     settings_current.multiface3 ? BST_CHECKED : BST_UNCHECKED, 0 );
445 
446   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_MULTIFACE1_STEALTH, BM_SETCHECK,
447     settings_current.multiface1_stealth ? BST_CHECKED : BST_UNCHECKED, 0 );
448 
449   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_PRINTER, BM_SETCHECK,
450     settings_current.printer ? BST_CHECKED : BST_UNCHECKED, 0 );
451 
452   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_ZXPRINTER, BM_SETCHECK,
453     settings_current.zxprinter ? BST_CHECKED : BST_UNCHECKED, 0 );
454 
455   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_SPECCYBOOT, BM_SETCHECK,
456     settings_current.speccyboot ? BST_CHECKED : BST_UNCHECKED, 0 );
457 
458   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_SPECDRUM, BM_SETCHECK,
459     settings_current.specdrum ? BST_CHECKED : BST_UNCHECKED, 0 );
460 
461   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_TTX2000S, BM_SETCHECK,
462     settings_current.ttx2000s ? BST_CHECKED : BST_UNCHECKED, 0 );
463 
464   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_USOURCE, BM_SETCHECK,
465     settings_current.usource ? BST_CHECKED : BST_UNCHECKED, 0 );
466 
467   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_COVOX, BM_SETCHECK,
468     settings_current.covox ? BST_CHECKED : BST_UNCHECKED, 0 );
469 
470 }
471 
472 static void
menu_options_peripherals_general_done(HWND hwndDlg)473 menu_options_peripherals_general_done( HWND hwndDlg )
474 {
475   char buffer[80];
476 
477   buffer[0] = '\0';
478   if( buffer[0] ) {};          /* Shut gcc up */
479 
480   /* Get a copy of current settings */
481   settings_info original_settings;
482   memset( &original_settings, 0, sizeof( settings_info ) );
483   settings_copy( &original_settings, &settings_current );
484 
485   settings_current.joy_kempston =
486     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_JOY_KEMPSTON );
487 
488   settings_current.kempston_mouse =
489     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_KEMPSTON_MOUSE );
490 
491   settings_current.mouse_swap_buttons =
492     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_MOUSE_SWAP_BUTTONS );
493 
494   settings_current.fuller =
495     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_FULLER );
496 
497   settings_current.melodik =
498     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_MELODIK );
499 
500   settings_current.interface1 =
501     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_INTERFACE1 );
502 
503   settings_current.interface2 =
504     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_INTERFACE2 );
505 
506   settings_current.multiface1 =
507     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_MULTIFACE1 );
508 
509   settings_current.multiface128 =
510     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_MULTIFACE128 );
511 
512   settings_current.multiface3 =
513     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_MULTIFACE3 );
514 
515   settings_current.multiface1_stealth =
516     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_MULTIFACE1_STEALTH );
517 
518   settings_current.printer =
519     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_PRINTER );
520 
521   settings_current.zxprinter =
522     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_ZXPRINTER );
523 
524   settings_current.speccyboot =
525     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_SPECCYBOOT );
526 
527   settings_current.specdrum =
528     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_SPECDRUM );
529 
530   settings_current.ttx2000s =
531     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_TTX2000S );
532 
533   settings_current.usource =
534     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_USOURCE );
535 
536   settings_current.covox =
537     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_GENERAL_COVOX );
538 
539   int needs_hard_reset = periph_postcheck();
540 
541   /* Confirm reset */
542   if( needs_hard_reset ) {
543     ShowWindow( hwndDlg, SW_HIDE );
544 
545     if( !win32ui_confirm("Some options need to reset the machine. Reset?" ) ) {
546       /* Cancel new settings */
547       settings_copy( &settings_current, &original_settings );
548       settings_free( &original_settings );
549 
550       ShowWindow( hwndDlg, SW_SHOW );
551       return;
552     }
553   }
554 
555   settings_free( &original_settings );
556 
557   periph_posthook();
558 
559   win32statusbar_set_visibility( settings_current.statusbar );
560   display_refresh_all();
561 
562   EndDialog( hwndDlg, 0 );
563 }
564 
565 static BOOL CALLBACK
menu_options_peripherals_general_proc(HWND hwndDlg,UINT msg,WPARAM wParam GCC_UNUSED,LPARAM lParam GCC_UNUSED)566 menu_options_peripherals_general_proc( HWND hwndDlg, UINT msg, WPARAM wParam GCC_UNUSED,
567                               LPARAM lParam GCC_UNUSED )
568 {
569   switch( msg )
570   {
571     case WM_INITDIALOG:
572     {
573       /* FIXME: save the handle returned by LoadIcon() in win32ui.c */
574       SendMessage( hwndDlg, WM_SETICON, ICON_SMALL,
575                    (LPARAM)LoadIcon( fuse_hInstance, "win32_icon" ) );
576 
577       /* initialize the controls with current settings */
578       menu_options_peripherals_general_init( hwndDlg );
579 
580       return TRUE;
581     }
582 
583     case WM_COMMAND:
584       switch( LOWORD( wParam ) )
585       {
586         case IDOK:
587           /* Read the controls and apply the settings */
588           menu_options_peripherals_general_done( hwndDlg );
589           return 0;
590 
591         case IDCANCEL:
592           EndDialog( hwndDlg, 0 );
593           return 0;
594       }
595       break;
596 
597     case WM_CLOSE:
598       EndDialog( hwndDlg, 0 );
599       return 0;
600   }
601 
602   return FALSE;
603 }
604 
605 void
menu_options_peripherals_general(int action GCC_UNUSED)606 menu_options_peripherals_general( int action GCC_UNUSED )
607 {
608   fuse_emulation_pause();
609 
610   DialogBox( fuse_hInstance, MAKEINTRESOURCE( IDD_OPT_PERIPHERALS_GENERAL ),
611              fuse_hWnd, (DLGPROC) menu_options_peripherals_general_proc );
612 
613   fuse_emulation_unpause();
614 }
615 
616 static void
menu_options_peripherals_disk_init(HWND hwndDlg)617 menu_options_peripherals_disk_init( HWND hwndDlg )
618 {
619   char buffer[80];
620   int i;
621 
622   i = 0;
623   buffer[0] = '\0';
624   if( buffer[i] ) {};          /* Shut gcc up */
625 
626   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_SIMPLEIDE_ACTIVE, BM_SETCHECK,
627     settings_current.simpleide_active ? BST_CHECKED : BST_UNCHECKED, 0 );
628 
629   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_ZXATASP_ACTIVE, BM_SETCHECK,
630     settings_current.zxatasp_active ? BST_CHECKED : BST_UNCHECKED, 0 );
631 
632   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_ZXATASP_UPLOAD, BM_SETCHECK,
633     settings_current.zxatasp_upload ? BST_CHECKED : BST_UNCHECKED, 0 );
634 
635   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_ZXATASP_WP, BM_SETCHECK,
636     settings_current.zxatasp_wp ? BST_CHECKED : BST_UNCHECKED, 0 );
637 
638   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_ZXCF_ACTIVE, BM_SETCHECK,
639     settings_current.zxcf_active ? BST_CHECKED : BST_UNCHECKED, 0 );
640 
641   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_ZXCF_UPLOAD, BM_SETCHECK,
642     settings_current.zxcf_upload ? BST_CHECKED : BST_UNCHECKED, 0 );
643 
644   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_DIVIDE_ENABLED, BM_SETCHECK,
645     settings_current.divide_enabled ? BST_CHECKED : BST_UNCHECKED, 0 );
646 
647   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_DIVIDE_WP, BM_SETCHECK,
648     settings_current.divide_wp ? BST_CHECKED : BST_UNCHECKED, 0 );
649 
650   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_DIVMMC_ENABLED, BM_SETCHECK,
651     settings_current.divmmc_enabled ? BST_CHECKED : BST_UNCHECKED, 0 );
652 
653   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_DIVMMC_WP, BM_SETCHECK,
654     settings_current.divmmc_wp ? BST_CHECKED : BST_UNCHECKED, 0 );
655 
656   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_PLUSD, BM_SETCHECK,
657     settings_current.plusd ? BST_CHECKED : BST_UNCHECKED, 0 );
658 
659   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_DIDAKTIK80, BM_SETCHECK,
660     settings_current.didaktik80 ? BST_CHECKED : BST_UNCHECKED, 0 );
661 
662   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_DISCIPLE, BM_SETCHECK,
663     settings_current.disciple ? BST_CHECKED : BST_UNCHECKED, 0 );
664 
665   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_BETA128, BM_SETCHECK,
666     settings_current.beta128 ? BST_CHECKED : BST_UNCHECKED, 0 );
667 
668   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_BETA128_48BOOT, BM_SETCHECK,
669     settings_current.beta128_48boot ? BST_CHECKED : BST_UNCHECKED, 0 );
670 
671   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_OPUS, BM_SETCHECK,
672     settings_current.opus ? BST_CHECKED : BST_UNCHECKED, 0 );
673 
674   SendDlgItemMessage( hwndDlg, IDC_OPT_PERIPHERALS_DISK_ZXMMC_ENABLED, BM_SETCHECK,
675     settings_current.zxmmc_enabled ? BST_CHECKED : BST_UNCHECKED, 0 );
676 
677 }
678 
679 static void
menu_options_peripherals_disk_done(HWND hwndDlg)680 menu_options_peripherals_disk_done( HWND hwndDlg )
681 {
682   char buffer[80];
683 
684   buffer[0] = '\0';
685   if( buffer[0] ) {};          /* Shut gcc up */
686 
687   /* Get a copy of current settings */
688   settings_info original_settings;
689   memset( &original_settings, 0, sizeof( settings_info ) );
690   settings_copy( &original_settings, &settings_current );
691 
692   settings_current.simpleide_active =
693     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_SIMPLEIDE_ACTIVE );
694 
695   settings_current.zxatasp_active =
696     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_ZXATASP_ACTIVE );
697 
698   settings_current.zxatasp_upload =
699     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_ZXATASP_UPLOAD );
700 
701   settings_current.zxatasp_wp =
702     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_ZXATASP_WP );
703 
704   settings_current.zxcf_active =
705     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_ZXCF_ACTIVE );
706 
707   settings_current.zxcf_upload =
708     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_ZXCF_UPLOAD );
709 
710   settings_current.divide_enabled =
711     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_DIVIDE_ENABLED );
712 
713   settings_current.divide_wp =
714     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_DIVIDE_WP );
715 
716   settings_current.divmmc_enabled =
717     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_DIVMMC_ENABLED );
718 
719   settings_current.divmmc_wp =
720     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_DIVMMC_WP );
721 
722   settings_current.plusd =
723     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_PLUSD );
724 
725   settings_current.didaktik80 =
726     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_DIDAKTIK80 );
727 
728   settings_current.disciple =
729     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_DISCIPLE );
730 
731   settings_current.beta128 =
732     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_BETA128 );
733 
734   settings_current.beta128_48boot =
735     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_BETA128_48BOOT );
736 
737   settings_current.opus =
738     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_OPUS );
739 
740   settings_current.zxmmc_enabled =
741     IsDlgButtonChecked( hwndDlg, IDC_OPT_PERIPHERALS_DISK_ZXMMC_ENABLED );
742 
743   int needs_hard_reset = periph_postcheck();
744 
745   /* Confirm reset */
746   if( needs_hard_reset ) {
747     ShowWindow( hwndDlg, SW_HIDE );
748 
749     if( !win32ui_confirm("Some options need to reset the machine. Reset?" ) ) {
750       /* Cancel new settings */
751       settings_copy( &settings_current, &original_settings );
752       settings_free( &original_settings );
753 
754       ShowWindow( hwndDlg, SW_SHOW );
755       return;
756     }
757   }
758 
759   settings_free( &original_settings );
760 
761   periph_posthook();
762 
763   win32statusbar_set_visibility( settings_current.statusbar );
764   display_refresh_all();
765 
766   EndDialog( hwndDlg, 0 );
767 }
768 
769 static BOOL CALLBACK
menu_options_peripherals_disk_proc(HWND hwndDlg,UINT msg,WPARAM wParam GCC_UNUSED,LPARAM lParam GCC_UNUSED)770 menu_options_peripherals_disk_proc( HWND hwndDlg, UINT msg, WPARAM wParam GCC_UNUSED,
771                               LPARAM lParam GCC_UNUSED )
772 {
773   switch( msg )
774   {
775     case WM_INITDIALOG:
776     {
777       /* FIXME: save the handle returned by LoadIcon() in win32ui.c */
778       SendMessage( hwndDlg, WM_SETICON, ICON_SMALL,
779                    (LPARAM)LoadIcon( fuse_hInstance, "win32_icon" ) );
780 
781       /* initialize the controls with current settings */
782       menu_options_peripherals_disk_init( hwndDlg );
783 
784       return TRUE;
785     }
786 
787     case WM_COMMAND:
788       switch( LOWORD( wParam ) )
789       {
790         case IDOK:
791           /* Read the controls and apply the settings */
792           menu_options_peripherals_disk_done( hwndDlg );
793           return 0;
794 
795         case IDCANCEL:
796           EndDialog( hwndDlg, 0 );
797           return 0;
798       }
799       break;
800 
801     case WM_CLOSE:
802       EndDialog( hwndDlg, 0 );
803       return 0;
804   }
805 
806   return FALSE;
807 }
808 
809 void
menu_options_peripherals_disk(int action GCC_UNUSED)810 menu_options_peripherals_disk( int action GCC_UNUSED )
811 {
812   fuse_emulation_pause();
813 
814   DialogBox( fuse_hInstance, MAKEINTRESOURCE( IDD_OPT_PERIPHERALS_DISK ),
815              fuse_hWnd, (DLGPROC) menu_options_peripherals_disk_proc );
816 
817   fuse_emulation_unpause();
818 }
819 
820 static void
menu_options_rzx_init(HWND hwndDlg)821 menu_options_rzx_init( HWND hwndDlg )
822 {
823   char buffer[80];
824   int i;
825 
826   i = 0;
827   buffer[0] = '\0';
828   if( buffer[i] ) {};          /* Shut gcc up */
829 
830   SendDlgItemMessage( hwndDlg, IDC_OPT_RZX_RZX_AUTOSAVES, BM_SETCHECK,
831     settings_current.rzx_autosaves ? BST_CHECKED : BST_UNCHECKED, 0 );
832 
833   SendDlgItemMessage( hwndDlg, IDC_OPT_RZX_RZX_COMPRESSION, BM_SETCHECK,
834     settings_current.rzx_compression ? BST_CHECKED : BST_UNCHECKED, 0 );
835 
836   SendDlgItemMessage( hwndDlg, IDC_OPT_RZX_COMPETITION_MODE, BM_SETCHECK,
837     settings_current.competition_mode ? BST_CHECKED : BST_UNCHECKED, 0 );
838 
839   SendDlgItemMessage( hwndDlg, IDC_OPT_RZX_COMPETITION_CODE, EM_LIMITTEXT,
840                       8, 0 );
841   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
842   snprintf( buffer, 80, "%d", settings_current.competition_code );
843   SendDlgItemMessage( hwndDlg, IDC_OPT_RZX_COMPETITION_CODE, WM_SETTEXT,
844                       0, (LPARAM) buffer );
845 
846   SendDlgItemMessage( hwndDlg, IDC_OPT_RZX_EMBED_SNAPSHOT, BM_SETCHECK,
847     settings_current.embed_snapshot ? BST_CHECKED : BST_UNCHECKED, 0 );
848 
849 }
850 
851 static void
menu_options_rzx_done(HWND hwndDlg)852 menu_options_rzx_done( HWND hwndDlg )
853 {
854   char buffer[80];
855 
856   buffer[0] = '\0';
857   if( buffer[0] ) {};          /* Shut gcc up */
858 
859   settings_current.rzx_autosaves =
860     IsDlgButtonChecked( hwndDlg, IDC_OPT_RZX_RZX_AUTOSAVES );
861 
862   settings_current.rzx_compression =
863     IsDlgButtonChecked( hwndDlg, IDC_OPT_RZX_RZX_COMPRESSION );
864 
865   settings_current.competition_mode =
866     IsDlgButtonChecked( hwndDlg, IDC_OPT_RZX_COMPETITION_MODE );
867 
868   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
869   SendDlgItemMessage( hwndDlg, IDC_OPT_RZX_COMPETITION_CODE, WM_GETTEXT,
870                       80, (LPARAM) buffer );
871   settings_current.competition_code = atoi( buffer );
872 
873   settings_current.embed_snapshot =
874     IsDlgButtonChecked( hwndDlg, IDC_OPT_RZX_EMBED_SNAPSHOT );
875 
876   win32statusbar_set_visibility( settings_current.statusbar );
877   display_refresh_all();
878 
879   EndDialog( hwndDlg, 0 );
880 }
881 
882 static BOOL CALLBACK
menu_options_rzx_proc(HWND hwndDlg,UINT msg,WPARAM wParam GCC_UNUSED,LPARAM lParam GCC_UNUSED)883 menu_options_rzx_proc( HWND hwndDlg, UINT msg, WPARAM wParam GCC_UNUSED,
884                               LPARAM lParam GCC_UNUSED )
885 {
886   switch( msg )
887   {
888     case WM_INITDIALOG:
889     {
890       /* FIXME: save the handle returned by LoadIcon() in win32ui.c */
891       SendMessage( hwndDlg, WM_SETICON, ICON_SMALL,
892                    (LPARAM)LoadIcon( fuse_hInstance, "win32_icon" ) );
893 
894       /* initialize the controls with current settings */
895       menu_options_rzx_init( hwndDlg );
896 
897       return TRUE;
898     }
899 
900     case WM_COMMAND:
901       switch( LOWORD( wParam ) )
902       {
903         case IDOK:
904           /* Read the controls and apply the settings */
905           menu_options_rzx_done( hwndDlg );
906           return 0;
907 
908         case IDCANCEL:
909           EndDialog( hwndDlg, 0 );
910           return 0;
911       }
912       break;
913 
914     case WM_CLOSE:
915       EndDialog( hwndDlg, 0 );
916       return 0;
917   }
918 
919   return FALSE;
920 }
921 
922 void
menu_options_rzx(int action GCC_UNUSED)923 menu_options_rzx( int action GCC_UNUSED )
924 {
925   fuse_emulation_pause();
926 
927   DialogBox( fuse_hInstance, MAKEINTRESOURCE( IDD_OPT_RZX ),
928              fuse_hWnd, (DLGPROC) menu_options_rzx_proc );
929 
930   fuse_emulation_unpause();
931 }
932 
933 
934 static const char * const sound_stereo_ay_combo[] = {
935   "None",
936   "ACB",
937   "ABC",
938 };
939 
940 static const int sound_stereo_ay_combo_count = 3;
941 
942 int
option_enumerate_sound_stereo_ay(void)943 option_enumerate_sound_stereo_ay( void ) {
944   return option_enumerate_combo( sound_stereo_ay_combo,
945                                  settings_current.stereo_ay,
946                                  sound_stereo_ay_combo_count,
947                                  0 );
948 }
949 
950 
951 static const char * const sound_speaker_type_combo[] = {
952   "TV speaker",
953   "Beeper",
954   "Unfiltered",
955 };
956 
957 static const int sound_speaker_type_combo_count = 3;
958 
959 int
option_enumerate_sound_speaker_type(void)960 option_enumerate_sound_speaker_type( void ) {
961   return option_enumerate_combo( sound_speaker_type_combo,
962                                  settings_current.speaker_type,
963                                  sound_speaker_type_combo_count,
964                                  0 );
965 }
966 
967 static void
menu_options_sound_init(HWND hwndDlg)968 menu_options_sound_init( HWND hwndDlg )
969 {
970   char buffer[80];
971   int i;
972 
973   i = 0;
974   buffer[0] = '\0';
975   if( buffer[i] ) {};          /* Shut gcc up */
976 
977   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_SOUND, BM_SETCHECK,
978     settings_current.sound ? BST_CHECKED : BST_UNCHECKED, 0 );
979 
980   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_SOUND_LOAD, BM_SETCHECK,
981     settings_current.sound_load ? BST_CHECKED : BST_UNCHECKED, 0 );
982 
983   for( i = 0; i < sound_stereo_ay_combo_count; i++ ) {
984     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
985     SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_STEREO_AY, CB_ADDSTRING,
986                         0, (LPARAM) sound_stereo_ay_combo[i] );
987   }
988   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_STEREO_AY, CB_SETCURSEL,
989                       (LPARAM) 0, 0 );
990   if( settings_current.stereo_ay != NULL ) {
991     for( i = 0; i < sound_stereo_ay_combo_count; i++ ) {
992       if( !strcmp( settings_current.stereo_ay,
993                    sound_stereo_ay_combo[i] ) ) {
994         SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_STEREO_AY,
995                             CB_SETCURSEL, i, 0 );
996       }
997     }
998   }
999   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_SOUND_FORCE_8BIT, BM_SETCHECK,
1000     settings_current.sound_force_8bit ? BST_CHECKED : BST_UNCHECKED, 0 );
1001 
1002   for( i = 0; i < sound_speaker_type_combo_count; i++ ) {
1003     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1004     SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_SPEAKER_TYPE, CB_ADDSTRING,
1005                         0, (LPARAM) sound_speaker_type_combo[i] );
1006   }
1007   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_SPEAKER_TYPE, CB_SETCURSEL,
1008                       (LPARAM) 0, 0 );
1009   if( settings_current.speaker_type != NULL ) {
1010     for( i = 0; i < sound_speaker_type_combo_count; i++ ) {
1011       if( !strcmp( settings_current.speaker_type,
1012                    sound_speaker_type_combo[i] ) ) {
1013         SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_SPEAKER_TYPE,
1014                             CB_SETCURSEL, i, 0 );
1015       }
1016     }
1017   }
1018   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_VOLUME_AY, EM_LIMITTEXT,
1019                       3, 0 );
1020   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1021   snprintf( buffer, 80, "%d", settings_current.volume_ay );
1022   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_VOLUME_AY, WM_SETTEXT,
1023                       0, (LPARAM) buffer );
1024 
1025   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_VOLUME_BEEPER, EM_LIMITTEXT,
1026                       3, 0 );
1027   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1028   snprintf( buffer, 80, "%d", settings_current.volume_beeper );
1029   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_VOLUME_BEEPER, WM_SETTEXT,
1030                       0, (LPARAM) buffer );
1031 
1032   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_VOLUME_SPECDRUM, EM_LIMITTEXT,
1033                       3, 0 );
1034   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1035   snprintf( buffer, 80, "%d", settings_current.volume_specdrum );
1036   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_VOLUME_SPECDRUM, WM_SETTEXT,
1037                       0, (LPARAM) buffer );
1038 
1039   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_VOLUME_COVOX, EM_LIMITTEXT,
1040                       3, 0 );
1041   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1042   snprintf( buffer, 80, "%d", settings_current.volume_covox );
1043   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_VOLUME_COVOX, WM_SETTEXT,
1044                       0, (LPARAM) buffer );
1045 
1046 }
1047 
1048 static void
menu_options_sound_done(HWND hwndDlg)1049 menu_options_sound_done( HWND hwndDlg )
1050 {
1051   char buffer[80];
1052 
1053   buffer[0] = '\0';
1054   if( buffer[0] ) {};          /* Shut gcc up */
1055 
1056   settings_current.sound =
1057     IsDlgButtonChecked( hwndDlg, IDC_OPT_SOUND_SOUND );
1058 
1059   settings_current.sound_load =
1060     IsDlgButtonChecked( hwndDlg, IDC_OPT_SOUND_SOUND_LOAD );
1061 
1062   libspectrum_free( settings_current.stereo_ay );
1063   settings_current.stereo_ay =
1064     utils_safe_strdup( sound_stereo_ay_combo[
1065     SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_STEREO_AY, CB_GETCURSEL, 0, 0 ) ] );
1066 
1067   settings_current.sound_force_8bit =
1068     IsDlgButtonChecked( hwndDlg, IDC_OPT_SOUND_SOUND_FORCE_8BIT );
1069 
1070   libspectrum_free( settings_current.speaker_type );
1071   settings_current.speaker_type =
1072     utils_safe_strdup( sound_speaker_type_combo[
1073     SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_SPEAKER_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1074 
1075   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1076   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_VOLUME_AY, WM_GETTEXT,
1077                       80, (LPARAM) buffer );
1078   settings_current.volume_ay = atoi( buffer );
1079 
1080   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1081   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_VOLUME_BEEPER, WM_GETTEXT,
1082                       80, (LPARAM) buffer );
1083   settings_current.volume_beeper = atoi( buffer );
1084 
1085   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1086   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_VOLUME_SPECDRUM, WM_GETTEXT,
1087                       80, (LPARAM) buffer );
1088   settings_current.volume_specdrum = atoi( buffer );
1089 
1090   /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1091   SendDlgItemMessage( hwndDlg, IDC_OPT_SOUND_VOLUME_COVOX, WM_GETTEXT,
1092                       80, (LPARAM) buffer );
1093   settings_current.volume_covox = atoi( buffer );
1094 
1095   win32statusbar_set_visibility( settings_current.statusbar );
1096   display_refresh_all();
1097 
1098   EndDialog( hwndDlg, 0 );
1099 }
1100 
1101 static BOOL CALLBACK
menu_options_sound_proc(HWND hwndDlg,UINT msg,WPARAM wParam GCC_UNUSED,LPARAM lParam GCC_UNUSED)1102 menu_options_sound_proc( HWND hwndDlg, UINT msg, WPARAM wParam GCC_UNUSED,
1103                               LPARAM lParam GCC_UNUSED )
1104 {
1105   switch( msg )
1106   {
1107     case WM_INITDIALOG:
1108     {
1109       /* FIXME: save the handle returned by LoadIcon() in win32ui.c */
1110       SendMessage( hwndDlg, WM_SETICON, ICON_SMALL,
1111                    (LPARAM)LoadIcon( fuse_hInstance, "win32_icon" ) );
1112 
1113       /* initialize the controls with current settings */
1114       menu_options_sound_init( hwndDlg );
1115 
1116       return TRUE;
1117     }
1118 
1119     case WM_COMMAND:
1120       switch( LOWORD( wParam ) )
1121       {
1122         case IDOK:
1123           /* Read the controls and apply the settings */
1124           menu_options_sound_done( hwndDlg );
1125           return 0;
1126 
1127         case IDCANCEL:
1128           EndDialog( hwndDlg, 0 );
1129           return 0;
1130       }
1131       break;
1132 
1133     case WM_CLOSE:
1134       EndDialog( hwndDlg, 0 );
1135       return 0;
1136   }
1137 
1138   return FALSE;
1139 }
1140 
1141 void
menu_options_sound(int action GCC_UNUSED)1142 menu_options_sound( int action GCC_UNUSED )
1143 {
1144   fuse_emulation_pause();
1145 
1146   DialogBox( fuse_hInstance, MAKEINTRESOURCE( IDD_OPT_SOUND ),
1147              fuse_hWnd, (DLGPROC) menu_options_sound_proc );
1148 
1149   fuse_emulation_unpause();
1150 }
1151 
1152 
1153 static const char * const diskoptions_drive_plus3a_type_combo[] = {
1154   "Single-sided 40 track",
1155   "Double-sided 40 track",
1156   "Single-sided 80 track",
1157   "Double-sided 80 track",
1158 };
1159 
1160 static const int diskoptions_drive_plus3a_type_combo_count = 4;
1161 
1162 int
option_enumerate_diskoptions_drive_plus3a_type(void)1163 option_enumerate_diskoptions_drive_plus3a_type( void ) {
1164   return option_enumerate_combo( diskoptions_drive_plus3a_type_combo,
1165                                  settings_current.drive_plus3a_type,
1166                                  diskoptions_drive_plus3a_type_combo_count,
1167                                  0 );
1168 }
1169 
1170 
1171 static const char * const diskoptions_drive_plus3b_type_combo[] = {
1172   "Disabled",
1173   "Single-sided 40 track",
1174   "Double-sided 40 track",
1175   "Single-sided 80 track",
1176   "Double-sided 80 track",
1177 };
1178 
1179 static const int diskoptions_drive_plus3b_type_combo_count = 5;
1180 
1181 int
option_enumerate_diskoptions_drive_plus3b_type(void)1182 option_enumerate_diskoptions_drive_plus3b_type( void ) {
1183   return option_enumerate_combo( diskoptions_drive_plus3b_type_combo,
1184                                  settings_current.drive_plus3b_type,
1185                                  diskoptions_drive_plus3b_type_combo_count,
1186                                  4 );
1187 }
1188 
1189 #define diskoptions_drive_beta128a_type_combo diskoptions_drive_plus3a_type_combo
1190 #define diskoptions_drive_beta128a_type_combo_count diskoptions_drive_plus3a_type_combo_count
1191 
1192 int
option_enumerate_diskoptions_drive_beta128a_type(void)1193 option_enumerate_diskoptions_drive_beta128a_type( void ) {
1194   return option_enumerate_combo( diskoptions_drive_beta128a_type_combo,
1195                                  settings_current.drive_beta128a_type,
1196                                  diskoptions_drive_beta128a_type_combo_count,
1197                                  3 );
1198 }
1199 
1200 #define diskoptions_drive_beta128b_type_combo diskoptions_drive_plus3b_type_combo
1201 #define diskoptions_drive_beta128b_type_combo_count diskoptions_drive_plus3b_type_combo_count
1202 
1203 int
option_enumerate_diskoptions_drive_beta128b_type(void)1204 option_enumerate_diskoptions_drive_beta128b_type( void ) {
1205   return option_enumerate_combo( diskoptions_drive_beta128b_type_combo,
1206                                  settings_current.drive_beta128b_type,
1207                                  diskoptions_drive_beta128b_type_combo_count,
1208                                  4 );
1209 }
1210 
1211 #define diskoptions_drive_beta128c_type_combo diskoptions_drive_plus3b_type_combo
1212 #define diskoptions_drive_beta128c_type_combo_count diskoptions_drive_plus3b_type_combo_count
1213 
1214 int
option_enumerate_diskoptions_drive_beta128c_type(void)1215 option_enumerate_diskoptions_drive_beta128c_type( void ) {
1216   return option_enumerate_combo( diskoptions_drive_beta128c_type_combo,
1217                                  settings_current.drive_beta128c_type,
1218                                  diskoptions_drive_beta128c_type_combo_count,
1219                                  4 );
1220 }
1221 
1222 #define diskoptions_drive_beta128d_type_combo diskoptions_drive_plus3b_type_combo
1223 #define diskoptions_drive_beta128d_type_combo_count diskoptions_drive_plus3b_type_combo_count
1224 
1225 int
option_enumerate_diskoptions_drive_beta128d_type(void)1226 option_enumerate_diskoptions_drive_beta128d_type( void ) {
1227   return option_enumerate_combo( diskoptions_drive_beta128d_type_combo,
1228                                  settings_current.drive_beta128d_type,
1229                                  diskoptions_drive_beta128d_type_combo_count,
1230                                  4 );
1231 }
1232 
1233 #define diskoptions_drive_plusd1_type_combo diskoptions_drive_plus3a_type_combo
1234 #define diskoptions_drive_plusd1_type_combo_count diskoptions_drive_plus3a_type_combo_count
1235 
1236 int
option_enumerate_diskoptions_drive_plusd1_type(void)1237 option_enumerate_diskoptions_drive_plusd1_type( void ) {
1238   return option_enumerate_combo( diskoptions_drive_plusd1_type_combo,
1239                                  settings_current.drive_plusd1_type,
1240                                  diskoptions_drive_plusd1_type_combo_count,
1241                                  3 );
1242 }
1243 
1244 #define diskoptions_drive_plusd2_type_combo diskoptions_drive_plus3b_type_combo
1245 #define diskoptions_drive_plusd2_type_combo_count diskoptions_drive_plus3b_type_combo_count
1246 
1247 int
option_enumerate_diskoptions_drive_plusd2_type(void)1248 option_enumerate_diskoptions_drive_plusd2_type( void ) {
1249   return option_enumerate_combo( diskoptions_drive_plusd2_type_combo,
1250                                  settings_current.drive_plusd2_type,
1251                                  diskoptions_drive_plusd2_type_combo_count,
1252                                  4 );
1253 }
1254 
1255 #define diskoptions_drive_didaktik80a_type_combo diskoptions_drive_plus3a_type_combo
1256 #define diskoptions_drive_didaktik80a_type_combo_count diskoptions_drive_plus3a_type_combo_count
1257 
1258 int
option_enumerate_diskoptions_drive_didaktik80a_type(void)1259 option_enumerate_diskoptions_drive_didaktik80a_type( void ) {
1260   return option_enumerate_combo( diskoptions_drive_didaktik80a_type_combo,
1261                                  settings_current.drive_didaktik80a_type,
1262                                  diskoptions_drive_didaktik80a_type_combo_count,
1263                                  3 );
1264 }
1265 
1266 #define diskoptions_drive_didaktik80b_type_combo diskoptions_drive_plus3b_type_combo
1267 #define diskoptions_drive_didaktik80b_type_combo_count diskoptions_drive_plus3b_type_combo_count
1268 
1269 int
option_enumerate_diskoptions_drive_didaktik80b_type(void)1270 option_enumerate_diskoptions_drive_didaktik80b_type( void ) {
1271   return option_enumerate_combo( diskoptions_drive_didaktik80b_type_combo,
1272                                  settings_current.drive_didaktik80b_type,
1273                                  diskoptions_drive_didaktik80b_type_combo_count,
1274                                  4 );
1275 }
1276 
1277 #define diskoptions_drive_disciple1_type_combo diskoptions_drive_plus3a_type_combo
1278 #define diskoptions_drive_disciple1_type_combo_count diskoptions_drive_plus3a_type_combo_count
1279 
1280 int
option_enumerate_diskoptions_drive_disciple1_type(void)1281 option_enumerate_diskoptions_drive_disciple1_type( void ) {
1282   return option_enumerate_combo( diskoptions_drive_disciple1_type_combo,
1283                                  settings_current.drive_disciple1_type,
1284                                  diskoptions_drive_disciple1_type_combo_count,
1285                                  3 );
1286 }
1287 
1288 #define diskoptions_drive_disciple2_type_combo diskoptions_drive_plus3b_type_combo
1289 #define diskoptions_drive_disciple2_type_combo_count diskoptions_drive_plus3b_type_combo_count
1290 
1291 int
option_enumerate_diskoptions_drive_disciple2_type(void)1292 option_enumerate_diskoptions_drive_disciple2_type( void ) {
1293   return option_enumerate_combo( diskoptions_drive_disciple2_type_combo,
1294                                  settings_current.drive_disciple2_type,
1295                                  diskoptions_drive_disciple2_type_combo_count,
1296                                  4 );
1297 }
1298 
1299 #define diskoptions_drive_opus1_type_combo diskoptions_drive_plus3a_type_combo
1300 #define diskoptions_drive_opus1_type_combo_count diskoptions_drive_plus3a_type_combo_count
1301 
1302 int
option_enumerate_diskoptions_drive_opus1_type(void)1303 option_enumerate_diskoptions_drive_opus1_type( void ) {
1304   return option_enumerate_combo( diskoptions_drive_opus1_type_combo,
1305                                  settings_current.drive_opus1_type,
1306                                  diskoptions_drive_opus1_type_combo_count,
1307                                  0 );
1308 }
1309 
1310 #define diskoptions_drive_opus2_type_combo diskoptions_drive_plus3b_type_combo
1311 #define diskoptions_drive_opus2_type_combo_count diskoptions_drive_plus3b_type_combo_count
1312 
1313 int
option_enumerate_diskoptions_drive_opus2_type(void)1314 option_enumerate_diskoptions_drive_opus2_type( void ) {
1315   return option_enumerate_combo( diskoptions_drive_opus2_type_combo,
1316                                  settings_current.drive_opus2_type,
1317                                  diskoptions_drive_opus2_type_combo_count,
1318                                  1 );
1319 }
1320 
1321 
1322 static const char * const diskoptions_disk_try_merge_combo[] = {
1323   "Never",
1324   "With single-sided drives",
1325   "Always",
1326 };
1327 
1328 static const int diskoptions_disk_try_merge_combo_count = 3;
1329 
1330 int
option_enumerate_diskoptions_disk_try_merge(void)1331 option_enumerate_diskoptions_disk_try_merge( void ) {
1332   return option_enumerate_combo( diskoptions_disk_try_merge_combo,
1333                                  settings_current.disk_try_merge,
1334                                  diskoptions_disk_try_merge_combo_count,
1335                                  1 );
1336 }
1337 
1338 static void
menu_options_diskoptions_init(HWND hwndDlg)1339 menu_options_diskoptions_init( HWND hwndDlg )
1340 {
1341   char buffer[80];
1342   int i;
1343 
1344   i = 0;
1345   buffer[0] = '\0';
1346   if( buffer[i] ) {};          /* Shut gcc up */
1347 
1348   for( i = 0; i < diskoptions_drive_plus3a_type_combo_count; i++ ) {
1349     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1350     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUS3A_TYPE, CB_ADDSTRING,
1351                         0, (LPARAM) diskoptions_drive_plus3a_type_combo[i] );
1352   }
1353   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUS3A_TYPE, CB_SETCURSEL,
1354                       (LPARAM) 0, 0 );
1355   if( settings_current.drive_plus3a_type != NULL ) {
1356     for( i = 0; i < diskoptions_drive_plus3a_type_combo_count; i++ ) {
1357       if( !strcmp( settings_current.drive_plus3a_type,
1358                    diskoptions_drive_plus3a_type_combo[i] ) ) {
1359         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUS3A_TYPE,
1360                             CB_SETCURSEL, i, 0 );
1361       }
1362     }
1363   }
1364   for( i = 0; i < diskoptions_drive_plus3b_type_combo_count; i++ ) {
1365     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1366     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUS3B_TYPE, CB_ADDSTRING,
1367                         0, (LPARAM) diskoptions_drive_plus3b_type_combo[i] );
1368   }
1369   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUS3B_TYPE, CB_SETCURSEL,
1370                       (LPARAM) 4, 0 );
1371   if( settings_current.drive_plus3b_type != NULL ) {
1372     for( i = 0; i < diskoptions_drive_plus3b_type_combo_count; i++ ) {
1373       if( !strcmp( settings_current.drive_plus3b_type,
1374                    diskoptions_drive_plus3b_type_combo[i] ) ) {
1375         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUS3B_TYPE,
1376                             CB_SETCURSEL, i, 0 );
1377       }
1378     }
1379   }
1380   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_PLUS3_DETECT_SPEEDLOCK, BM_SETCHECK,
1381     settings_current.plus3_detect_speedlock ? BST_CHECKED : BST_UNCHECKED, 0 );
1382 
1383   for( i = 0; i < diskoptions_drive_beta128a_type_combo_count; i++ ) {
1384     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1385     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128A_TYPE, CB_ADDSTRING,
1386                         0, (LPARAM) diskoptions_drive_beta128a_type_combo[i] );
1387   }
1388   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128A_TYPE, CB_SETCURSEL,
1389                       (LPARAM) 3, 0 );
1390   if( settings_current.drive_beta128a_type != NULL ) {
1391     for( i = 0; i < diskoptions_drive_beta128a_type_combo_count; i++ ) {
1392       if( !strcmp( settings_current.drive_beta128a_type,
1393                    diskoptions_drive_beta128a_type_combo[i] ) ) {
1394         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128A_TYPE,
1395                             CB_SETCURSEL, i, 0 );
1396       }
1397     }
1398   }
1399   for( i = 0; i < diskoptions_drive_beta128b_type_combo_count; i++ ) {
1400     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1401     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128B_TYPE, CB_ADDSTRING,
1402                         0, (LPARAM) diskoptions_drive_beta128b_type_combo[i] );
1403   }
1404   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128B_TYPE, CB_SETCURSEL,
1405                       (LPARAM) 4, 0 );
1406   if( settings_current.drive_beta128b_type != NULL ) {
1407     for( i = 0; i < diskoptions_drive_beta128b_type_combo_count; i++ ) {
1408       if( !strcmp( settings_current.drive_beta128b_type,
1409                    diskoptions_drive_beta128b_type_combo[i] ) ) {
1410         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128B_TYPE,
1411                             CB_SETCURSEL, i, 0 );
1412       }
1413     }
1414   }
1415   for( i = 0; i < diskoptions_drive_beta128c_type_combo_count; i++ ) {
1416     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1417     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128C_TYPE, CB_ADDSTRING,
1418                         0, (LPARAM) diskoptions_drive_beta128c_type_combo[i] );
1419   }
1420   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128C_TYPE, CB_SETCURSEL,
1421                       (LPARAM) 4, 0 );
1422   if( settings_current.drive_beta128c_type != NULL ) {
1423     for( i = 0; i < diskoptions_drive_beta128c_type_combo_count; i++ ) {
1424       if( !strcmp( settings_current.drive_beta128c_type,
1425                    diskoptions_drive_beta128c_type_combo[i] ) ) {
1426         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128C_TYPE,
1427                             CB_SETCURSEL, i, 0 );
1428       }
1429     }
1430   }
1431   for( i = 0; i < diskoptions_drive_beta128d_type_combo_count; i++ ) {
1432     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1433     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128D_TYPE, CB_ADDSTRING,
1434                         0, (LPARAM) diskoptions_drive_beta128d_type_combo[i] );
1435   }
1436   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128D_TYPE, CB_SETCURSEL,
1437                       (LPARAM) 4, 0 );
1438   if( settings_current.drive_beta128d_type != NULL ) {
1439     for( i = 0; i < diskoptions_drive_beta128d_type_combo_count; i++ ) {
1440       if( !strcmp( settings_current.drive_beta128d_type,
1441                    diskoptions_drive_beta128d_type_combo[i] ) ) {
1442         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128D_TYPE,
1443                             CB_SETCURSEL, i, 0 );
1444       }
1445     }
1446   }
1447   for( i = 0; i < diskoptions_drive_plusd1_type_combo_count; i++ ) {
1448     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1449     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUSD1_TYPE, CB_ADDSTRING,
1450                         0, (LPARAM) diskoptions_drive_plusd1_type_combo[i] );
1451   }
1452   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUSD1_TYPE, CB_SETCURSEL,
1453                       (LPARAM) 3, 0 );
1454   if( settings_current.drive_plusd1_type != NULL ) {
1455     for( i = 0; i < diskoptions_drive_plusd1_type_combo_count; i++ ) {
1456       if( !strcmp( settings_current.drive_plusd1_type,
1457                    diskoptions_drive_plusd1_type_combo[i] ) ) {
1458         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUSD1_TYPE,
1459                             CB_SETCURSEL, i, 0 );
1460       }
1461     }
1462   }
1463   for( i = 0; i < diskoptions_drive_plusd2_type_combo_count; i++ ) {
1464     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1465     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUSD2_TYPE, CB_ADDSTRING,
1466                         0, (LPARAM) diskoptions_drive_plusd2_type_combo[i] );
1467   }
1468   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUSD2_TYPE, CB_SETCURSEL,
1469                       (LPARAM) 4, 0 );
1470   if( settings_current.drive_plusd2_type != NULL ) {
1471     for( i = 0; i < diskoptions_drive_plusd2_type_combo_count; i++ ) {
1472       if( !strcmp( settings_current.drive_plusd2_type,
1473                    diskoptions_drive_plusd2_type_combo[i] ) ) {
1474         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUSD2_TYPE,
1475                             CB_SETCURSEL, i, 0 );
1476       }
1477     }
1478   }
1479   for( i = 0; i < diskoptions_drive_didaktik80a_type_combo_count; i++ ) {
1480     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1481     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DIDAKTIK80A_TYPE, CB_ADDSTRING,
1482                         0, (LPARAM) diskoptions_drive_didaktik80a_type_combo[i] );
1483   }
1484   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DIDAKTIK80A_TYPE, CB_SETCURSEL,
1485                       (LPARAM) 3, 0 );
1486   if( settings_current.drive_didaktik80a_type != NULL ) {
1487     for( i = 0; i < diskoptions_drive_didaktik80a_type_combo_count; i++ ) {
1488       if( !strcmp( settings_current.drive_didaktik80a_type,
1489                    diskoptions_drive_didaktik80a_type_combo[i] ) ) {
1490         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DIDAKTIK80A_TYPE,
1491                             CB_SETCURSEL, i, 0 );
1492       }
1493     }
1494   }
1495   for( i = 0; i < diskoptions_drive_didaktik80b_type_combo_count; i++ ) {
1496     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1497     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DIDAKTIK80B_TYPE, CB_ADDSTRING,
1498                         0, (LPARAM) diskoptions_drive_didaktik80b_type_combo[i] );
1499   }
1500   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DIDAKTIK80B_TYPE, CB_SETCURSEL,
1501                       (LPARAM) 4, 0 );
1502   if( settings_current.drive_didaktik80b_type != NULL ) {
1503     for( i = 0; i < diskoptions_drive_didaktik80b_type_combo_count; i++ ) {
1504       if( !strcmp( settings_current.drive_didaktik80b_type,
1505                    diskoptions_drive_didaktik80b_type_combo[i] ) ) {
1506         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DIDAKTIK80B_TYPE,
1507                             CB_SETCURSEL, i, 0 );
1508       }
1509     }
1510   }
1511   for( i = 0; i < diskoptions_drive_disciple1_type_combo_count; i++ ) {
1512     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1513     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DISCIPLE1_TYPE, CB_ADDSTRING,
1514                         0, (LPARAM) diskoptions_drive_disciple1_type_combo[i] );
1515   }
1516   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DISCIPLE1_TYPE, CB_SETCURSEL,
1517                       (LPARAM) 3, 0 );
1518   if( settings_current.drive_disciple1_type != NULL ) {
1519     for( i = 0; i < diskoptions_drive_disciple1_type_combo_count; i++ ) {
1520       if( !strcmp( settings_current.drive_disciple1_type,
1521                    diskoptions_drive_disciple1_type_combo[i] ) ) {
1522         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DISCIPLE1_TYPE,
1523                             CB_SETCURSEL, i, 0 );
1524       }
1525     }
1526   }
1527   for( i = 0; i < diskoptions_drive_disciple2_type_combo_count; i++ ) {
1528     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1529     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DISCIPLE2_TYPE, CB_ADDSTRING,
1530                         0, (LPARAM) diskoptions_drive_disciple2_type_combo[i] );
1531   }
1532   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DISCIPLE2_TYPE, CB_SETCURSEL,
1533                       (LPARAM) 4, 0 );
1534   if( settings_current.drive_disciple2_type != NULL ) {
1535     for( i = 0; i < diskoptions_drive_disciple2_type_combo_count; i++ ) {
1536       if( !strcmp( settings_current.drive_disciple2_type,
1537                    diskoptions_drive_disciple2_type_combo[i] ) ) {
1538         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DISCIPLE2_TYPE,
1539                             CB_SETCURSEL, i, 0 );
1540       }
1541     }
1542   }
1543   for( i = 0; i < diskoptions_drive_opus1_type_combo_count; i++ ) {
1544     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1545     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_OPUS1_TYPE, CB_ADDSTRING,
1546                         0, (LPARAM) diskoptions_drive_opus1_type_combo[i] );
1547   }
1548   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_OPUS1_TYPE, CB_SETCURSEL,
1549                       (LPARAM) 0, 0 );
1550   if( settings_current.drive_opus1_type != NULL ) {
1551     for( i = 0; i < diskoptions_drive_opus1_type_combo_count; i++ ) {
1552       if( !strcmp( settings_current.drive_opus1_type,
1553                    diskoptions_drive_opus1_type_combo[i] ) ) {
1554         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_OPUS1_TYPE,
1555                             CB_SETCURSEL, i, 0 );
1556       }
1557     }
1558   }
1559   for( i = 0; i < diskoptions_drive_opus2_type_combo_count; i++ ) {
1560     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1561     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_OPUS2_TYPE, CB_ADDSTRING,
1562                         0, (LPARAM) diskoptions_drive_opus2_type_combo[i] );
1563   }
1564   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_OPUS2_TYPE, CB_SETCURSEL,
1565                       (LPARAM) 1, 0 );
1566   if( settings_current.drive_opus2_type != NULL ) {
1567     for( i = 0; i < diskoptions_drive_opus2_type_combo_count; i++ ) {
1568       if( !strcmp( settings_current.drive_opus2_type,
1569                    diskoptions_drive_opus2_type_combo[i] ) ) {
1570         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_OPUS2_TYPE,
1571                             CB_SETCURSEL, i, 0 );
1572       }
1573     }
1574   }
1575   for( i = 0; i < diskoptions_disk_try_merge_combo_count; i++ ) {
1576     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1577     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DISK_TRY_MERGE, CB_ADDSTRING,
1578                         0, (LPARAM) diskoptions_disk_try_merge_combo[i] );
1579   }
1580   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DISK_TRY_MERGE, CB_SETCURSEL,
1581                       (LPARAM) 1, 0 );
1582   if( settings_current.disk_try_merge != NULL ) {
1583     for( i = 0; i < diskoptions_disk_try_merge_combo_count; i++ ) {
1584       if( !strcmp( settings_current.disk_try_merge,
1585                    diskoptions_disk_try_merge_combo[i] ) ) {
1586         SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DISK_TRY_MERGE,
1587                             CB_SETCURSEL, i, 0 );
1588       }
1589     }
1590   }
1591   SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DISK_ASK_MERGE, BM_SETCHECK,
1592     settings_current.disk_ask_merge ? BST_CHECKED : BST_UNCHECKED, 0 );
1593 
1594 }
1595 
1596 static void
menu_options_diskoptions_done(HWND hwndDlg)1597 menu_options_diskoptions_done( HWND hwndDlg )
1598 {
1599   char buffer[80];
1600 
1601   buffer[0] = '\0';
1602   if( buffer[0] ) {};          /* Shut gcc up */
1603 
1604   libspectrum_free( settings_current.drive_plus3a_type );
1605   settings_current.drive_plus3a_type =
1606     utils_safe_strdup( diskoptions_drive_plus3a_type_combo[
1607     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUS3A_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1608 
1609   libspectrum_free( settings_current.drive_plus3b_type );
1610   settings_current.drive_plus3b_type =
1611     utils_safe_strdup( diskoptions_drive_plus3b_type_combo[
1612     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUS3B_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1613 
1614   settings_current.plus3_detect_speedlock =
1615     IsDlgButtonChecked( hwndDlg, IDC_OPT_DISKOPTIONS_PLUS3_DETECT_SPEEDLOCK );
1616 
1617   libspectrum_free( settings_current.drive_beta128a_type );
1618   settings_current.drive_beta128a_type =
1619     utils_safe_strdup( diskoptions_drive_beta128a_type_combo[
1620     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128A_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1621 
1622   libspectrum_free( settings_current.drive_beta128b_type );
1623   settings_current.drive_beta128b_type =
1624     utils_safe_strdup( diskoptions_drive_beta128b_type_combo[
1625     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128B_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1626 
1627   libspectrum_free( settings_current.drive_beta128c_type );
1628   settings_current.drive_beta128c_type =
1629     utils_safe_strdup( diskoptions_drive_beta128c_type_combo[
1630     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128C_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1631 
1632   libspectrum_free( settings_current.drive_beta128d_type );
1633   settings_current.drive_beta128d_type =
1634     utils_safe_strdup( diskoptions_drive_beta128d_type_combo[
1635     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_BETA128D_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1636 
1637   libspectrum_free( settings_current.drive_plusd1_type );
1638   settings_current.drive_plusd1_type =
1639     utils_safe_strdup( diskoptions_drive_plusd1_type_combo[
1640     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUSD1_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1641 
1642   libspectrum_free( settings_current.drive_plusd2_type );
1643   settings_current.drive_plusd2_type =
1644     utils_safe_strdup( diskoptions_drive_plusd2_type_combo[
1645     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_PLUSD2_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1646 
1647   libspectrum_free( settings_current.drive_didaktik80a_type );
1648   settings_current.drive_didaktik80a_type =
1649     utils_safe_strdup( diskoptions_drive_didaktik80a_type_combo[
1650     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DIDAKTIK80A_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1651 
1652   libspectrum_free( settings_current.drive_didaktik80b_type );
1653   settings_current.drive_didaktik80b_type =
1654     utils_safe_strdup( diskoptions_drive_didaktik80b_type_combo[
1655     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DIDAKTIK80B_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1656 
1657   libspectrum_free( settings_current.drive_disciple1_type );
1658   settings_current.drive_disciple1_type =
1659     utils_safe_strdup( diskoptions_drive_disciple1_type_combo[
1660     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DISCIPLE1_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1661 
1662   libspectrum_free( settings_current.drive_disciple2_type );
1663   settings_current.drive_disciple2_type =
1664     utils_safe_strdup( diskoptions_drive_disciple2_type_combo[
1665     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_DISCIPLE2_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1666 
1667   libspectrum_free( settings_current.drive_opus1_type );
1668   settings_current.drive_opus1_type =
1669     utils_safe_strdup( diskoptions_drive_opus1_type_combo[
1670     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_OPUS1_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1671 
1672   libspectrum_free( settings_current.drive_opus2_type );
1673   settings_current.drive_opus2_type =
1674     utils_safe_strdup( diskoptions_drive_opus2_type_combo[
1675     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DRIVE_OPUS2_TYPE, CB_GETCURSEL, 0, 0 ) ] );
1676 
1677   libspectrum_free( settings_current.disk_try_merge );
1678   settings_current.disk_try_merge =
1679     utils_safe_strdup( diskoptions_disk_try_merge_combo[
1680     SendDlgItemMessage( hwndDlg, IDC_OPT_DISKOPTIONS_DISK_TRY_MERGE, CB_GETCURSEL, 0, 0 ) ] );
1681 
1682   settings_current.disk_ask_merge =
1683     IsDlgButtonChecked( hwndDlg, IDC_OPT_DISKOPTIONS_DISK_ASK_MERGE );
1684 
1685   win32statusbar_set_visibility( settings_current.statusbar );
1686   display_refresh_all();
1687 
1688   EndDialog( hwndDlg, 0 );
1689 }
1690 
1691 static BOOL CALLBACK
menu_options_diskoptions_proc(HWND hwndDlg,UINT msg,WPARAM wParam GCC_UNUSED,LPARAM lParam GCC_UNUSED)1692 menu_options_diskoptions_proc( HWND hwndDlg, UINT msg, WPARAM wParam GCC_UNUSED,
1693                               LPARAM lParam GCC_UNUSED )
1694 {
1695   switch( msg )
1696   {
1697     case WM_INITDIALOG:
1698     {
1699       /* FIXME: save the handle returned by LoadIcon() in win32ui.c */
1700       SendMessage( hwndDlg, WM_SETICON, ICON_SMALL,
1701                    (LPARAM)LoadIcon( fuse_hInstance, "win32_icon" ) );
1702 
1703       /* initialize the controls with current settings */
1704       menu_options_diskoptions_init( hwndDlg );
1705 
1706       return TRUE;
1707     }
1708 
1709     case WM_COMMAND:
1710       switch( LOWORD( wParam ) )
1711       {
1712         case IDOK:
1713           /* Read the controls and apply the settings */
1714           menu_options_diskoptions_done( hwndDlg );
1715           return 0;
1716 
1717         case IDCANCEL:
1718           EndDialog( hwndDlg, 0 );
1719           return 0;
1720       }
1721       break;
1722 
1723     case WM_CLOSE:
1724       EndDialog( hwndDlg, 0 );
1725       return 0;
1726   }
1727 
1728   return FALSE;
1729 }
1730 
1731 void
menu_options_diskoptions(int action GCC_UNUSED)1732 menu_options_diskoptions( int action GCC_UNUSED )
1733 {
1734   fuse_emulation_pause();
1735 
1736   DialogBox( fuse_hInstance, MAKEINTRESOURCE( IDD_OPT_DISKOPTIONS ),
1737              fuse_hWnd, (DLGPROC) menu_options_diskoptions_proc );
1738 
1739   fuse_emulation_unpause();
1740 }
1741 
1742 
1743 static const char * const movie_movie_compr_combo[] = {
1744   "None",
1745   "Lossless",
1746   "High",
1747 };
1748 
1749 static const int movie_movie_compr_combo_count = 3;
1750 
1751 int
option_enumerate_movie_movie_compr(void)1752 option_enumerate_movie_movie_compr( void ) {
1753   return option_enumerate_combo( movie_movie_compr_combo,
1754                                  settings_current.movie_compr,
1755                                  movie_movie_compr_combo_count,
1756                                  1 );
1757 }
1758 
1759 static void
menu_options_movie_init(HWND hwndDlg)1760 menu_options_movie_init( HWND hwndDlg )
1761 {
1762   char buffer[80];
1763   int i;
1764 
1765   i = 0;
1766   buffer[0] = '\0';
1767   if( buffer[i] ) {};          /* Shut gcc up */
1768 
1769   for( i = 0; i < movie_movie_compr_combo_count; i++ ) {
1770     /* FIXME This is asuming SendDlgItemMessage is not UNICODE */
1771     SendDlgItemMessage( hwndDlg, IDC_OPT_MOVIE_MOVIE_COMPR, CB_ADDSTRING,
1772                         0, (LPARAM) movie_movie_compr_combo[i] );
1773   }
1774   SendDlgItemMessage( hwndDlg, IDC_OPT_MOVIE_MOVIE_COMPR, CB_SETCURSEL,
1775                       (LPARAM) 1, 0 );
1776   if( settings_current.movie_compr != NULL ) {
1777     for( i = 0; i < movie_movie_compr_combo_count; i++ ) {
1778       if( !strcmp( settings_current.movie_compr,
1779                    movie_movie_compr_combo[i] ) ) {
1780         SendDlgItemMessage( hwndDlg, IDC_OPT_MOVIE_MOVIE_COMPR,
1781                             CB_SETCURSEL, i, 0 );
1782       }
1783     }
1784   }
1785   SendDlgItemMessage( hwndDlg, IDC_OPT_MOVIE_MOVIE_STOP_AFTER_RZX, BM_SETCHECK,
1786     settings_current.movie_stop_after_rzx ? BST_CHECKED : BST_UNCHECKED, 0 );
1787 
1788 }
1789 
1790 static void
menu_options_movie_done(HWND hwndDlg)1791 menu_options_movie_done( HWND hwndDlg )
1792 {
1793   char buffer[80];
1794 
1795   buffer[0] = '\0';
1796   if( buffer[0] ) {};          /* Shut gcc up */
1797 
1798   libspectrum_free( settings_current.movie_compr );
1799   settings_current.movie_compr =
1800     utils_safe_strdup( movie_movie_compr_combo[
1801     SendDlgItemMessage( hwndDlg, IDC_OPT_MOVIE_MOVIE_COMPR, CB_GETCURSEL, 0, 0 ) ] );
1802 
1803   settings_current.movie_stop_after_rzx =
1804     IsDlgButtonChecked( hwndDlg, IDC_OPT_MOVIE_MOVIE_STOP_AFTER_RZX );
1805 
1806   win32statusbar_set_visibility( settings_current.statusbar );
1807   display_refresh_all();
1808 
1809   EndDialog( hwndDlg, 0 );
1810 }
1811 
1812 static BOOL CALLBACK
menu_options_movie_proc(HWND hwndDlg,UINT msg,WPARAM wParam GCC_UNUSED,LPARAM lParam GCC_UNUSED)1813 menu_options_movie_proc( HWND hwndDlg, UINT msg, WPARAM wParam GCC_UNUSED,
1814                               LPARAM lParam GCC_UNUSED )
1815 {
1816   switch( msg )
1817   {
1818     case WM_INITDIALOG:
1819     {
1820       /* FIXME: save the handle returned by LoadIcon() in win32ui.c */
1821       SendMessage( hwndDlg, WM_SETICON, ICON_SMALL,
1822                    (LPARAM)LoadIcon( fuse_hInstance, "win32_icon" ) );
1823 
1824       /* initialize the controls with current settings */
1825       menu_options_movie_init( hwndDlg );
1826 
1827       return TRUE;
1828     }
1829 
1830     case WM_COMMAND:
1831       switch( LOWORD( wParam ) )
1832       {
1833         case IDOK:
1834           /* Read the controls and apply the settings */
1835           menu_options_movie_done( hwndDlg );
1836           return 0;
1837 
1838         case IDCANCEL:
1839           EndDialog( hwndDlg, 0 );
1840           return 0;
1841       }
1842       break;
1843 
1844     case WM_CLOSE:
1845       EndDialog( hwndDlg, 0 );
1846       return 0;
1847   }
1848 
1849   return FALSE;
1850 }
1851 
1852 void
menu_options_movie(int action GCC_UNUSED)1853 menu_options_movie( int action GCC_UNUSED )
1854 {
1855   fuse_emulation_pause();
1856 
1857   DialogBox( fuse_hInstance, MAKEINTRESOURCE( IDD_OPT_MOVIE ),
1858              fuse_hWnd, (DLGPROC) menu_options_movie_proc );
1859 
1860   fuse_emulation_unpause();
1861 }
1862 
1863 
1864 #endif                 /* #ifdef UI_WIN32 */
1865 
1866