1 /* menu.c: general menu callbacks
2 Copyright (c) 2004-2005 Philip Kendall
3
4 $Id: menu.c 4841 2013-01-02 01:55:24Z zubzero $
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20 Author contact information:
21
22 Philip Kendall <philip-fuse@shadowmagic.org.uk>
23
24 */
25
26 #include <config.h>
27
28 #include <libspectrum.h>
29
30 #include "event.h"
31 #include "fuse.h"
32 #include "menu.h"
33 #include "movie.h"
34 #include "machines/specplus3.h"
35 #include "peripherals/dck.h"
36 #include "peripherals/disk/beta.h"
37 #include "peripherals/disk/disciple.h"
38 #include "peripherals/disk/opus.h"
39 #include "peripherals/disk/plusd.h"
40 #include "peripherals/ide/divide.h"
41 #include "peripherals/ide/simpleide.h"
42 #include "peripherals/ide/zxatasp.h"
43 #include "peripherals/ide/zxcf.h"
44 #include "peripherals/if1.h"
45 #include "peripherals/if2.h"
46 #include "peripherals/joystick.h"
47 #include "profile.h"
48 #include "psg.h"
49 #include "rzx.h"
50 #include "screenshot.h"
51 #include "settings.h"
52 #include "snapshot.h"
53 #include "tape.h"
54 #include "ui/scaler/scaler.h"
55 #include "ui/ui.h"
56 #include "utils.h"
57 #include "z80/z80.h"
58
MENU_CALLBACK(menu_file_open)59 MENU_CALLBACK( menu_file_open )
60 {
61 char *filename;
62
63 fuse_emulation_pause();
64
65 filename = ui_get_open_filename( "Fuse - Open Spectrum File" );
66 if( !filename ) { fuse_emulation_unpause(); return; }
67
68 utils_open_file( filename, tape_can_autoload(), NULL );
69
70 libspectrum_free( filename );
71
72 display_refresh_all();
73
74 fuse_emulation_unpause();
75 }
76
MENU_CALLBACK(menu_file_recording_insertsnapshot)77 MENU_CALLBACK( menu_file_recording_insertsnapshot )
78 {
79 libspectrum_snap *snap;
80 libspectrum_error error;
81
82 if( !rzx_recording ) return;
83
84 ui_widget_finish();
85
86 libspectrum_rzx_stop_input( rzx );
87
88 snap = libspectrum_snap_alloc();
89
90 error = snapshot_copy_to( snap );
91 if( error ) { libspectrum_snap_free( snap ); return; }
92
93 libspectrum_rzx_add_snap( rzx, snap, 0 );
94
95 libspectrum_rzx_start_input( rzx, tstates );
96 }
97
MENU_CALLBACK(menu_file_recording_rollback)98 MENU_CALLBACK( menu_file_recording_rollback )
99 {
100 libspectrum_error error;
101
102 if( !rzx_recording ) return;
103
104 ui_widget_finish();
105
106 fuse_emulation_pause();
107
108 error = rzx_rollback();
109 if( error ) { fuse_emulation_unpause(); return; }
110
111 fuse_emulation_unpause();
112 }
113
MENU_CALLBACK(menu_file_recording_rollbackto)114 MENU_CALLBACK( menu_file_recording_rollbackto )
115 {
116 libspectrum_error error;
117
118 if( !rzx_recording ) return;
119
120 ui_widget_finish();
121
122 fuse_emulation_pause();
123
124 error = rzx_rollback_to();
125 if( error ) { fuse_emulation_unpause(); return; }
126
127 fuse_emulation_unpause();
128 }
129
MENU_CALLBACK(menu_file_recording_play)130 MENU_CALLBACK( menu_file_recording_play )
131 {
132 char *recording;
133
134 if( rzx_playback || rzx_recording ) return;
135
136 fuse_emulation_pause();
137
138 recording = ui_get_open_filename( "Fuse - Start Replay" );
139 if( !recording ) { fuse_emulation_unpause(); return; }
140
141 rzx_start_playback( recording, 1 );
142
143 libspectrum_free( recording );
144
145 display_refresh_all();
146
147 if( rzx_playback ) ui_menu_activate( UI_MENU_ITEM_RECORDING, 1 );
148
149 fuse_emulation_unpause();
150 }
151
MENU_CALLBACK(menu_file_recording_stop)152 MENU_CALLBACK( menu_file_recording_stop )
153 {
154 if( !( rzx_recording || rzx_playback ) ) return;
155
156 ui_widget_finish();
157
158 if( rzx_recording ) rzx_stop_recording();
159 if( rzx_playback ) rzx_stop_playback( 1 );
160 }
161
MENU_CALLBACK(menu_file_aylogging_stop)162 MENU_CALLBACK( menu_file_aylogging_stop )
163 {
164 if ( !psg_recording ) return;
165
166 ui_widget_finish();
167
168 psg_stop_recording();
169 ui_menu_activate( UI_MENU_ITEM_AY_LOGGING, 0 );
170 }
171
MENU_CALLBACK(menu_file_openscrscreenshot)172 MENU_CALLBACK( menu_file_openscrscreenshot )
173 {
174 char *filename;
175
176 fuse_emulation_pause();
177
178 filename = ui_get_open_filename( "Fuse - Open SCR Screenshot" );
179 if( !filename ) { fuse_emulation_unpause(); return; }
180
181 screenshot_scr_read( filename );
182
183 libspectrum_free( filename );
184
185 fuse_emulation_unpause();
186 }
187
MENU_CALLBACK(menu_file_movie_stop)188 MENU_CALLBACK( menu_file_movie_stop )
189 {
190 ui_widget_finish();
191
192 movie_stop();
193 }
194
MENU_CALLBACK(menu_file_movie_pause)195 MENU_CALLBACK( menu_file_movie_pause )
196 {
197 ui_widget_finish();
198
199 movie_pause();
200 }
201
MENU_CALLBACK_WITH_ACTION(menu_options_selectroms_select)202 MENU_CALLBACK_WITH_ACTION( menu_options_selectroms_select )
203 {
204 switch( action ) {
205
206 case 1: menu_select_roms( LIBSPECTRUM_MACHINE_16, 0, 1 ); return;
207 case 2: menu_select_roms( LIBSPECTRUM_MACHINE_48, 1, 1 ); return;
208 case 3: menu_select_roms( LIBSPECTRUM_MACHINE_128, 2, 2 ); return;
209 case 4: menu_select_roms( LIBSPECTRUM_MACHINE_PLUS2, 4, 2 ); return;
210 case 5: menu_select_roms( LIBSPECTRUM_MACHINE_PLUS2A, 6, 4 ); return;
211 case 6: menu_select_roms( LIBSPECTRUM_MACHINE_PLUS3, 10, 4 ); return;
212 case 7: menu_select_roms( LIBSPECTRUM_MACHINE_PLUS3E, 14, 4 ); return;
213 case 8: menu_select_roms( LIBSPECTRUM_MACHINE_TC2048, 18, 1 ); return;
214 case 9: menu_select_roms( LIBSPECTRUM_MACHINE_TC2068, 19, 2 ); return;
215 case 10: menu_select_roms( LIBSPECTRUM_MACHINE_TS2068, 21, 2 ); return;
216 case 11: menu_select_roms( LIBSPECTRUM_MACHINE_PENT, 23, 3 ); return;
217 case 12: menu_select_roms( LIBSPECTRUM_MACHINE_PENT512, 26, 4 ); return;
218 case 13: menu_select_roms( LIBSPECTRUM_MACHINE_PENT1024, 30, 4 ); return;
219 case 14: menu_select_roms( LIBSPECTRUM_MACHINE_SCORP, 34, 4 ); return;
220 case 15: menu_select_roms( LIBSPECTRUM_MACHINE_SE, 38, 2 ); return;
221
222 case 16: menu_select_roms_with_title( "Interface 1", 40, 1 ); return;
223 case 17: menu_select_roms_with_title( "Beta 128", 41, 1 ); return;
224 case 18: menu_select_roms_with_title( "+D", 42, 1 ); return;
225 case 19: menu_select_roms_with_title( "DISCiPLE", 43, 1 ); return;
226 case 20: menu_select_roms_with_title( "Opus Discovery", 44, 1 ); return;
227 case 21: menu_select_roms_with_title( "SpeccyBoot", 45, 1 ); return;
228
229 }
230
231 ui_error( UI_ERROR_ERROR,
232 "menu_options_selectroms_select: unknown action %d", action );
233 fuse_abort();
234 }
235
MENU_CALLBACK(menu_options_filter)236 MENU_CALLBACK( menu_options_filter )
237 {
238 scaler_type scaler;
239
240 /* Stop emulation */
241 fuse_emulation_pause();
242
243 scaler = menu_get_scaler( scaler_is_supported );
244 if( scaler != SCALER_NUM && scaler != current_scaler )
245 scaler_select_scaler( scaler );
246
247 /* Carry on with emulation again */
248 fuse_emulation_unpause();
249 }
250
MENU_CALLBACK(menu_options_fullscreen)251 MENU_CALLBACK( menu_options_fullscreen )
252 {
253 ui_widget_finish();
254 settings_current.full_screen = !settings_current.full_screen;
255 }
256
MENU_CALLBACK(menu_options_save)257 MENU_CALLBACK( menu_options_save )
258 {
259 ui_widget_finish();
260 settings_write_config( &settings_current );
261 }
262
MENU_CALLBACK(menu_machine_profiler_start)263 MENU_CALLBACK( menu_machine_profiler_start )
264 {
265 ui_widget_finish();
266 profile_start();
267 }
268
MENU_CALLBACK(menu_machine_profiler_stop)269 MENU_CALLBACK( menu_machine_profiler_stop )
270 {
271 char *filename;
272
273 fuse_emulation_pause();
274
275 filename = ui_get_save_filename( "Fuse - Save Profile Data" );
276 if( !filename ) { fuse_emulation_unpause(); return; }
277
278 profile_finish( filename );
279
280 libspectrum_free( filename );
281
282 fuse_emulation_unpause();
283 }
284
MENU_CALLBACK(menu_machine_nmi)285 MENU_CALLBACK( menu_machine_nmi )
286 {
287 ui_widget_finish();
288 event_add( 0, z80_nmi_event );
289 }
290
MENU_CALLBACK(menu_media_tape_open)291 MENU_CALLBACK( menu_media_tape_open )
292 {
293 char *filename;
294
295 fuse_emulation_pause();
296
297 filename = ui_get_open_filename( "Fuse - Open Tape" );
298 if( !filename ) { fuse_emulation_unpause(); return; }
299
300 tape_open( filename, 0 );
301
302 libspectrum_free( filename );
303
304 fuse_emulation_unpause();
305 }
306
MENU_CALLBACK(menu_media_tape_play)307 MENU_CALLBACK( menu_media_tape_play )
308 {
309 ui_widget_finish();
310 tape_toggle_play( 0 );
311 }
312
MENU_CALLBACK(menu_media_tape_rewind)313 MENU_CALLBACK( menu_media_tape_rewind )
314 {
315 ui_widget_finish();
316 tape_select_block( 0 );
317 }
318
MENU_CALLBACK(menu_media_tape_clear)319 MENU_CALLBACK( menu_media_tape_clear )
320 {
321 ui_widget_finish();
322 tape_close();
323 }
324
MENU_CALLBACK(menu_media_tape_write)325 MENU_CALLBACK( menu_media_tape_write )
326 {
327 ui_tape_write();
328 }
329
MENU_CALLBACK(menu_media_tape_recordstart)330 MENU_CALLBACK( menu_media_tape_recordstart )
331 {
332 ui_widget_finish();
333 tape_record_start();
334 }
335
MENU_CALLBACK(menu_media_tape_recordstop)336 MENU_CALLBACK( menu_media_tape_recordstop )
337 {
338 ui_widget_finish();
339 tape_record_stop();
340 }
341
MENU_CALLBACK_WITH_ACTION(menu_media_if1_rs232)342 MENU_CALLBACK_WITH_ACTION( menu_media_if1_rs232 )
343 {
344 char *filename;
345
346 fuse_emulation_pause();
347
348 if( action & 0xf0 ) {
349 ui_widget_finish();
350 if1_unplug( action & 0x0f );
351 } else {
352 filename = ui_get_open_filename( "Fuse - Select File for Communication" );
353 if( !filename ) { fuse_emulation_unpause(); return; }
354
355 if1_plug( filename, action );
356
357 libspectrum_free( filename );
358 }
359 fuse_emulation_unpause();
360
361 }
362
MENU_CALLBACK_WITH_ACTION(menu_media_insert_new)363 MENU_CALLBACK_WITH_ACTION( menu_media_insert_new )
364 {
365 int which, type;
366
367 ui_widget_finish();
368
369 action--;
370 which = action & 0x0f;
371 type = ( action & 0xf0 ) >> 4;
372
373 switch( type ) {
374 case 0:
375 specplus3_disk_insert( which, NULL, 0 );
376 break;
377 case 1:
378 beta_disk_insert( which, NULL, 0 );
379 break;
380 case 2:
381 plusd_disk_insert( which, NULL, 0 );
382 break;
383 case 3:
384 if1_mdr_insert( which, NULL );
385 break;
386 case 4:
387 opus_disk_insert( which, NULL, 0 );
388 break;
389 case 5:
390 disciple_disk_insert( which, NULL, 0 );
391 break;
392 }
393 }
394
MENU_CALLBACK_WITH_ACTION(menu_media_insert)395 MENU_CALLBACK_WITH_ACTION( menu_media_insert )
396 {
397 char *filename;
398 char title[80];
399 int which, type;
400
401 action--;
402 which = action & 0x0f;
403 type = ( action & 0xf0 ) >> 4;
404
405 fuse_emulation_pause();
406
407 switch( type ) {
408 case 0:
409 snprintf( title, 80, "Fuse - Insert +3 Disk %c:", 'A' + which );
410 break;
411 case 1:
412 snprintf( title, 80, "Fuse - Insert Beta Disk %c:", 'A' + which );
413 break;
414 case 2:
415 snprintf( title, 80, "Fuse - Insert +D Disk %i", which + 1 );
416 break;
417 case 3:
418 snprintf( title, 80, "Fuse - Insert Microdrive Cartridge %i", which + 1 );
419 break;
420 case 4:
421 snprintf( title, 80, "Fuse - Insert Opus Disk %i", which + 1 );
422 break;
423 case 5:
424 snprintf( title, 80, "Fuse - Insert DISCiPLE Disk %i", which + 1 );
425 break;
426 default:
427 return;
428 }
429 filename = ui_get_open_filename( title );
430 if( !filename ) { fuse_emulation_unpause(); return; }
431
432 switch( type ) {
433 case 0:
434 specplus3_disk_insert( which, filename, 0 );
435 break;
436 case 1:
437 beta_disk_insert( which, filename, 0 );
438 break;
439 case 2:
440 plusd_disk_insert( which, filename, 0 );
441 break;
442 case 3:
443 if1_mdr_insert( which, filename );
444 break;
445 case 4:
446 opus_disk_insert( which, filename, 0 );
447 break;
448 case 5:
449 disciple_disk_insert( which, filename, 0 );
450 break;
451 }
452
453 libspectrum_free( filename );
454
455 fuse_emulation_unpause();
456 }
457
MENU_CALLBACK_WITH_ACTION(menu_media_eject)458 MENU_CALLBACK_WITH_ACTION( menu_media_eject )
459 {
460 int which, type;
461
462 ui_widget_finish();
463
464 action--;
465 which = action & 0x00f;
466 type = ( action & 0x0f0 ) >> 4;
467
468 switch( type ) {
469 case 0:
470 specplus3_disk_eject( which );
471 break;
472 case 1:
473 beta_disk_eject( which );
474 break;
475 case 2:
476 plusd_disk_eject( which );
477 break;
478 case 3:
479 if1_mdr_eject( which );
480 break;
481 case 4:
482 opus_disk_eject( which );
483 break;
484 case 5:
485 disciple_disk_eject( which );
486 break;
487 }
488 }
489
MENU_CALLBACK_WITH_ACTION(menu_media_save)490 MENU_CALLBACK_WITH_ACTION( menu_media_save )
491 {
492 int which, saveas, type;
493
494 ui_widget_finish();
495
496 action--;
497 which = action & 0x00f;
498 type = ( action & 0x0f0 ) >> 4;
499 saveas = ( action & 0xf00 ) >> 8;
500
501 switch( type ) {
502 case 0:
503 specplus3_disk_save( which, saveas );
504 break;
505 case 1:
506 beta_disk_save( which, saveas );
507 break;
508 case 2:
509 plusd_disk_save( which, saveas );
510 break;
511 case 3:
512 if1_mdr_save( which, saveas );
513 break;
514 case 4:
515 opus_disk_save( which, saveas );
516 break;
517 case 5:
518 disciple_disk_save( which, saveas );
519 break;
520 }
521 }
522
MENU_CALLBACK_WITH_ACTION(menu_media_flip)523 MENU_CALLBACK_WITH_ACTION( menu_media_flip )
524 {
525 int which, type, flip;
526
527 ui_widget_finish();
528
529 action--;
530 which = action & 0x0f;
531 type = ( action & 0xf0 ) >> 4;
532 flip = !!( action & 0x100 );
533
534 switch( type ) {
535 case 0:
536 specplus3_disk_flip( which, flip );
537 break;
538 case 1:
539 beta_disk_flip( which, flip );
540 break;
541 case 2:
542 plusd_disk_flip( which, flip );
543 break;
544 /* No flip option for IF1 */
545 case 4:
546 opus_disk_flip( which, flip );
547 break;
548 case 5:
549 disciple_disk_flip( which, flip );
550 break;
551 }
552 }
553
MENU_CALLBACK_WITH_ACTION(menu_media_writeprotect)554 MENU_CALLBACK_WITH_ACTION( menu_media_writeprotect )
555 {
556 int which, wrprot, type;
557
558 ui_widget_finish();
559
560 action--;
561 which = action & 0x00f;
562 type = ( action & 0x0f0 ) >> 4;
563 wrprot = !!( action & 0x100 );
564
565 switch( type ) {
566 case 0:
567 specplus3_disk_writeprotect( which, wrprot );
568 break;
569 case 1:
570 beta_disk_writeprotect( which, wrprot );
571 break;
572 case 2:
573 plusd_disk_writeprotect( which, wrprot );
574 break;
575 case 3:
576 if1_mdr_writeprotect( which, wrprot );
577 break;
578 case 4:
579 opus_disk_writeprotect( which, wrprot );
580 break;
581 case 5:
582 disciple_disk_writeprotect( which, wrprot );
583 break;
584 }
585
586 }
587
MENU_CALLBACK(menu_media_cartridge_timexdock_insert)588 MENU_CALLBACK( menu_media_cartridge_timexdock_insert )
589 {
590 char *filename;
591
592 fuse_emulation_pause();
593
594 filename = ui_get_open_filename( "Fuse - Insert Timex Dock Cartridge" );
595 if( !filename ) { fuse_emulation_unpause(); return; }
596
597 dck_insert( filename );
598
599 libspectrum_free( filename );
600
601 fuse_emulation_unpause();
602 }
603
MENU_CALLBACK(menu_media_cartridge_timexdock_eject)604 MENU_CALLBACK( menu_media_cartridge_timexdock_eject )
605 {
606 ui_widget_finish();
607 dck_eject();
608 }
609
MENU_CALLBACK(menu_media_cartridge_interface2_insert)610 MENU_CALLBACK( menu_media_cartridge_interface2_insert )
611 {
612 char *filename;
613
614 fuse_emulation_pause();
615
616 filename = ui_get_open_filename( "Fuse - Insert Interface 2 Cartridge" );
617 if( !filename ) { fuse_emulation_unpause(); return; }
618
619 if2_insert( filename );
620
621 libspectrum_free( filename );
622
623 fuse_emulation_unpause();
624 }
625
MENU_CALLBACK(menu_media_cartridge_interface2_eject)626 MENU_CALLBACK( menu_media_cartridge_interface2_eject )
627 {
628 ui_widget_finish();
629 if2_eject();
630 }
631
MENU_CALLBACK_WITH_ACTION(menu_media_ide_insert)632 MENU_CALLBACK_WITH_ACTION( menu_media_ide_insert )
633 {
634 char *filename;
635
636 fuse_emulation_pause();
637
638 filename = ui_get_open_filename( "Fuse - Insert Hard Disk File" );
639 if( !filename ) { fuse_emulation_unpause(); return; }
640
641 switch( action ) {
642 case 1: simpleide_insert( filename, LIBSPECTRUM_IDE_MASTER ); break;
643 case 2: simpleide_insert( filename, LIBSPECTRUM_IDE_SLAVE ); break;
644 case 3: zxatasp_insert( filename, LIBSPECTRUM_IDE_MASTER ); break;
645 case 4: zxatasp_insert( filename, LIBSPECTRUM_IDE_SLAVE ); break;
646 case 5: zxcf_insert( filename ); break;
647 case 6: divide_insert( filename, LIBSPECTRUM_IDE_MASTER ); break;
648 case 7: divide_insert( filename, LIBSPECTRUM_IDE_SLAVE ); break;
649 }
650
651 libspectrum_free( filename );
652
653 fuse_emulation_unpause();
654 }
655
MENU_CALLBACK_WITH_ACTION(menu_media_ide_commit)656 MENU_CALLBACK_WITH_ACTION( menu_media_ide_commit )
657 {
658 fuse_emulation_pause();
659
660 switch( action ) {
661 case 1: simpleide_commit( LIBSPECTRUM_IDE_MASTER ); break;
662 case 2: simpleide_commit( LIBSPECTRUM_IDE_SLAVE ); break;
663 case 3: zxatasp_commit( LIBSPECTRUM_IDE_MASTER ); break;
664 case 4: zxatasp_commit( LIBSPECTRUM_IDE_SLAVE ); break;
665 case 5: zxcf_commit(); break;
666 case 6: divide_commit( LIBSPECTRUM_IDE_MASTER ); break;
667 case 7: divide_commit( LIBSPECTRUM_IDE_SLAVE ); break;
668 }
669
670 fuse_emulation_unpause();
671
672 ui_widget_finish();
673 }
674
MENU_CALLBACK_WITH_ACTION(menu_media_ide_eject)675 MENU_CALLBACK_WITH_ACTION( menu_media_ide_eject )
676 {
677 fuse_emulation_pause();
678
679 switch( action ) {
680 case 1: simpleide_eject( LIBSPECTRUM_IDE_MASTER ); break;
681 case 2: simpleide_eject( LIBSPECTRUM_IDE_SLAVE ); break;
682 case 3: zxatasp_eject( LIBSPECTRUM_IDE_MASTER ); break;
683 case 4: zxatasp_eject( LIBSPECTRUM_IDE_SLAVE ); break;
684 case 5: zxcf_eject(); break;
685 case 6: divide_eject( LIBSPECTRUM_IDE_MASTER ); break;
686 case 7: divide_eject( LIBSPECTRUM_IDE_SLAVE ); break;
687 }
688
689 fuse_emulation_unpause();
690
691 ui_widget_finish();
692 }
693
MENU_CALLBACK(menu_media_ide_zxatasp_upload)694 MENU_CALLBACK( menu_media_ide_zxatasp_upload )
695 {
696 settings_current.zxatasp_upload = !settings_current.zxatasp_upload;
697 ui_widget_finish();
698 }
699
MENU_CALLBACK(menu_media_ide_zxatasp_writeprotect)700 MENU_CALLBACK( menu_media_ide_zxatasp_writeprotect )
701 {
702 settings_current.zxatasp_wp = !settings_current.zxatasp_wp;
703 ui_widget_finish();
704 }
705
MENU_CALLBACK(menu_media_ide_zxcf_upload)706 MENU_CALLBACK( menu_media_ide_zxcf_upload )
707 {
708 settings_current.zxcf_upload = !settings_current.zxcf_upload;
709 ui_widget_finish();
710 }
711
MENU_CALLBACK(menu_media_ide_divide_writeprotect)712 MENU_CALLBACK( menu_media_ide_divide_writeprotect )
713 {
714 settings_current.divide_wp = !settings_current.divide_wp;
715 divide_refresh_page_state();
716 ui_widget_finish();
717 }
718
MENU_CALLBACK(menu_file_savesnapshot)719 MENU_CALLBACK( menu_file_savesnapshot )
720 {
721 char *filename;
722
723 ui_widget_finish();
724
725 fuse_emulation_pause();
726
727 filename = ui_get_save_filename( "Fuse - Save Snapshot" );
728 if( !filename ) { fuse_emulation_unpause(); return; }
729
730 snapshot_write( filename );
731
732 libspectrum_free( filename );
733
734 fuse_emulation_unpause();
735 }
736
MENU_CALLBACK(menu_file_savescreenasscr)737 MENU_CALLBACK( menu_file_savescreenasscr )
738 {
739 char *filename;
740
741 ui_widget_finish();
742
743 fuse_emulation_pause();
744
745 filename = ui_get_save_filename( "Fuse - Save Screenshot as SCR" );
746 if( !filename ) { fuse_emulation_unpause(); return; }
747
748 screenshot_scr_write( filename );
749
750 libspectrum_free( filename );
751
752 fuse_emulation_unpause();
753 }
754
755 #ifdef USE_LIBPNG
756
MENU_CALLBACK(menu_file_savescreenaspng)757 MENU_CALLBACK( menu_file_savescreenaspng )
758 {
759 scaler_type scaler;
760 char *filename;
761
762 ui_widget_finish();
763
764 fuse_emulation_pause();
765
766 scaler = menu_get_scaler( screenshot_available_scalers );
767 if( scaler == SCALER_NUM ) {
768 fuse_emulation_unpause();
769 return;
770 }
771
772 filename =
773 ui_get_save_filename( "Fuse - Save Screenshot as PNG" );
774 if( !filename ) { fuse_emulation_unpause(); return; }
775
776 screenshot_write( filename, scaler );
777
778 libspectrum_free( filename );
779
780 fuse_emulation_unpause();
781 }
782 #endif
783
MENU_CALLBACK(menu_file_movie_record)784 MENU_CALLBACK( menu_file_movie_record )
785 {
786 char *filename;
787
788 ui_widget_finish();
789
790 fuse_emulation_pause();
791
792 filename = ui_get_save_filename( "Fuse - Record Movie File" );
793 if( !filename ) { fuse_emulation_unpause(); return; }
794
795 movie_start( filename );
796 libspectrum_free( filename );
797
798 fuse_emulation_unpause();
799 }
800
MENU_CALLBACK(menu_file_movie_record_recordfromrzx)801 MENU_CALLBACK( menu_file_movie_record_recordfromrzx )
802 {
803 char *rzx_file, *fmf_file;
804
805 ui_widget_finish();
806
807 if( rzx_playback || rzx_recording || movie_recording ) return;
808
809 fuse_emulation_pause();
810
811 rzx_file = ui_get_open_filename( "Fuse - Load RZX" );
812 if( !rzx_file ) { fuse_emulation_unpause(); return; }
813
814 rzx_start_playback( rzx_file, 1 );
815 libspectrum_free( rzx_file );
816 display_refresh_all();
817
818 if( rzx_playback ) {
819 fmf_file = ui_get_save_filename( "Fuse - Record Movie File" );
820 if( !fmf_file ) {
821 rzx_stop_playback( 1 );
822 fuse_emulation_unpause();
823 return;
824 }
825
826 movie_start( fmf_file );
827 libspectrum_free( fmf_file );
828 ui_menu_activate( UI_MENU_ITEM_RECORDING, 1 );
829 }
830
831 fuse_emulation_unpause();
832 }
833
MENU_CALLBACK(menu_file_recording_record)834 MENU_CALLBACK( menu_file_recording_record )
835 {
836 char *recording;
837
838 if( rzx_playback || rzx_recording ) return;
839
840 fuse_emulation_pause();
841
842 recording = ui_get_save_filename( "Fuse - Start Recording" );
843 if( !recording ) { fuse_emulation_unpause(); return; }
844
845 rzx_start_recording( recording, 1 );
846
847 libspectrum_free( recording );
848
849 fuse_emulation_unpause();
850 }
851
MENU_CALLBACK(menu_file_recording_recordfromsnapshot)852 MENU_CALLBACK( menu_file_recording_recordfromsnapshot )
853 {
854 char *snap, *recording;
855
856 if( rzx_playback || rzx_recording ) return;
857
858 fuse_emulation_pause();
859
860 snap = ui_get_open_filename( "Fuse - Load Snapshot " );
861 if( !snap ) { fuse_emulation_unpause(); return; }
862
863 recording = ui_get_save_filename( "Fuse - Start Recording" );
864 if( !recording ) {
865 libspectrum_free( snap );
866 fuse_emulation_unpause();
867 return;
868 }
869
870 if( snapshot_read( snap ) ) {
871 libspectrum_free( snap );
872 libspectrum_free( recording );
873 fuse_emulation_unpause();
874 return;
875 }
876
877 rzx_start_recording( recording, settings_current.embed_snapshot );
878
879 libspectrum_free( recording );
880
881 display_refresh_all();
882
883 fuse_emulation_unpause();
884 }
885
MENU_CALLBACK(menu_file_aylogging_record)886 MENU_CALLBACK( menu_file_aylogging_record )
887 {
888 char *psgfile;
889
890 if( psg_recording ) return;
891
892 fuse_emulation_pause();
893
894 psgfile = ui_get_save_filename( "Fuse - Start AY Log" );
895 if( !psgfile ) { fuse_emulation_unpause(); return; }
896
897 psg_start_recording( psgfile );
898
899 libspectrum_free( psgfile );
900
901 display_refresh_all();
902
903 ui_menu_activate( UI_MENU_ITEM_AY_LOGGING, 1 );
904
905 fuse_emulation_unpause();
906 }
907
908 int
menu_check_media_changed(void)909 menu_check_media_changed( void )
910 {
911 int confirm, i;
912
913 confirm = tape_close(); if( confirm ) return 1;
914
915 confirm = specplus3_disk_eject( SPECPLUS3_DRIVE_A );
916 if( confirm ) return 1;
917
918 confirm = specplus3_disk_eject( SPECPLUS3_DRIVE_B );
919 if( confirm ) return 1;
920
921 confirm = beta_disk_eject( BETA_DRIVE_A );
922 if( confirm ) return 1;
923
924 confirm = beta_disk_eject( BETA_DRIVE_B );
925 if( confirm ) return 1;
926
927 confirm = beta_disk_eject( BETA_DRIVE_C );
928 if( confirm ) return 1;
929
930 confirm = beta_disk_eject( BETA_DRIVE_D );
931 if( confirm ) return 1;
932
933 confirm = opus_disk_eject( OPUS_DRIVE_1 );
934 if( confirm ) return 1;
935
936 confirm = opus_disk_eject( OPUS_DRIVE_2 );
937 if( confirm ) return 1;
938
939 confirm = plusd_disk_eject( PLUSD_DRIVE_1 );
940 if( confirm ) return 1;
941
942 confirm = plusd_disk_eject( PLUSD_DRIVE_2 );
943 if( confirm ) return 1;
944
945 confirm = disciple_disk_eject( DISCIPLE_DRIVE_1 );
946 if( confirm ) return 1;
947
948 confirm = disciple_disk_eject( DISCIPLE_DRIVE_2 );
949 if( confirm ) return 1;
950
951 for( i = 0; i < 8; i++ ) {
952 confirm = if1_mdr_eject( i );
953 if( confirm ) return 1;
954 }
955
956 if( settings_current.simpleide_master_file ) {
957 confirm = simpleide_eject( LIBSPECTRUM_IDE_MASTER );
958 if( confirm ) return 1;
959 }
960
961 if( settings_current.simpleide_slave_file ) {
962 confirm = simpleide_eject( LIBSPECTRUM_IDE_SLAVE );
963 if( confirm ) return 1;
964 }
965
966 if( settings_current.zxatasp_master_file ) {
967 confirm = zxatasp_eject( LIBSPECTRUM_IDE_MASTER );
968 if( confirm ) return 1;
969 }
970
971 if( settings_current.zxatasp_slave_file ) {
972 confirm = zxatasp_eject( LIBSPECTRUM_IDE_SLAVE );
973 if( confirm ) return 1;
974 }
975
976 if( settings_current.zxcf_pri_file ) {
977 confirm = zxcf_eject(); if( confirm ) return 1;
978 }
979
980 if( settings_current.divide_master_file ) {
981 confirm = divide_eject( LIBSPECTRUM_IDE_MASTER );
982 if( confirm ) return 1;
983 }
984
985 if( settings_current.divide_slave_file ) {
986 confirm = divide_eject( LIBSPECTRUM_IDE_SLAVE );
987 if( confirm ) return 1;
988 }
989
990 return 0;
991 }
992
993 int
menu_select_roms(libspectrum_machine machine,size_t start,size_t n)994 menu_select_roms( libspectrum_machine machine, size_t start, size_t n )
995 {
996 return menu_select_roms_with_title( libspectrum_machine_name( machine ),
997 start, n );
998 }
999
1000 const char*
menu_machine_detail(void)1001 menu_machine_detail( void )
1002 {
1003 return libspectrum_machine_name( machine_current->machine );
1004 }
1005
1006 const char*
menu_filter_detail(void)1007 menu_filter_detail( void )
1008 {
1009 return scaler_name(current_scaler);
1010 }
1011
1012 const char*
menu_keyboard_joystick_detail(void)1013 menu_keyboard_joystick_detail( void )
1014 {
1015 return joystick_name[ settings_current.joystick_keyboard_output ];
1016 }
1017
1018 const char*
menu_joystick_1_detail(void)1019 menu_joystick_1_detail( void )
1020 {
1021 return joystick_name[ settings_current.joystick_1_output ];
1022 }
1023
1024 const char*
menu_joystick_2_detail(void)1025 menu_joystick_2_detail( void )
1026 {
1027 return joystick_name[ settings_current.joystick_2_output ];
1028 }
1029
1030 const char*
menu_tape_detail(void)1031 menu_tape_detail( void )
1032 {
1033 if( !tape_present() ) return "Not inserted";
1034
1035 if( tape_is_playing() ) return "Playing";
1036 else return "Stopped";
1037 }
1038
1039 static const char *disk_detail_str[] = {
1040 "Inserted",
1041 "Inserted WP",
1042 "Inserted UD",
1043 "Inserted WP,UD",
1044 "Not inserted",
1045 };
1046
1047 static const char*
menu_disk_detail(fdd_t * f)1048 menu_disk_detail( fdd_t *f )
1049 {
1050 int i = 0;
1051
1052 if( !f->loaded ) return disk_detail_str[4];
1053 if( f->wrprot ) i = 1;
1054 if( f->upsidedown ) i += 2;
1055 return disk_detail_str[i];
1056 }
1057
1058 const char*
menu_plus3a_detail(void)1059 menu_plus3a_detail( void )
1060 {
1061 fdd_t *f = specplus3_get_fdd( SPECPLUS3_DRIVE_A );
1062
1063 return menu_disk_detail( f );
1064 }
1065
1066 const char*
menu_plus3b_detail(void)1067 menu_plus3b_detail( void )
1068 {
1069 fdd_t *f = specplus3_get_fdd( SPECPLUS3_DRIVE_B );
1070
1071 return menu_disk_detail( f );
1072 }
1073
1074 const char*
menu_beta128a_detail(void)1075 menu_beta128a_detail( void )
1076 {
1077 fdd_t *f = beta_get_fdd( BETA_DRIVE_A );
1078
1079 return menu_disk_detail( f );
1080 }
1081
1082 const char*
menu_beta128b_detail(void)1083 menu_beta128b_detail( void )
1084 {
1085 fdd_t *f = beta_get_fdd( BETA_DRIVE_B );
1086
1087 return menu_disk_detail( f );
1088 }
1089
1090 const char*
menu_beta128c_detail(void)1091 menu_beta128c_detail( void )
1092 {
1093 fdd_t *f = beta_get_fdd( BETA_DRIVE_C );
1094
1095 return menu_disk_detail( f );
1096 }
1097
1098 const char*
menu_beta128d_detail(void)1099 menu_beta128d_detail( void )
1100 {
1101 fdd_t *f = beta_get_fdd( BETA_DRIVE_D );
1102
1103 return menu_disk_detail( f );
1104 }
1105
1106 const char*
menu_opus1_detail(void)1107 menu_opus1_detail( void )
1108 {
1109 fdd_t *f = opus_get_fdd( OPUS_DRIVE_1 );
1110
1111 return menu_disk_detail( f );
1112 }
1113
1114 const char*
menu_opus2_detail(void)1115 menu_opus2_detail( void )
1116 {
1117 fdd_t *f = opus_get_fdd( OPUS_DRIVE_2 );
1118
1119 return menu_disk_detail( f );
1120 }
1121
1122 const char*
menu_plusd1_detail(void)1123 menu_plusd1_detail( void )
1124 {
1125 fdd_t *f = plusd_get_fdd( PLUSD_DRIVE_1 );
1126
1127 return menu_disk_detail( f );
1128 }
1129
1130 const char*
menu_plusd2_detail(void)1131 menu_plusd2_detail( void )
1132 {
1133 fdd_t *f = plusd_get_fdd( PLUSD_DRIVE_2 );
1134
1135 return menu_disk_detail( f );
1136 }
1137
1138 const char*
menu_disciple1_detail(void)1139 menu_disciple1_detail( void )
1140 {
1141 fdd_t *f = disciple_get_fdd( DISCIPLE_DRIVE_1 );
1142
1143 return menu_disk_detail( f );
1144 }
1145
1146 const char*
menu_disciple2_detail(void)1147 menu_disciple2_detail( void )
1148 {
1149 fdd_t *f = disciple_get_fdd( DISCIPLE_DRIVE_2 );
1150
1151 return menu_disk_detail( f );
1152 }
1153