20 |
|
|
21 |
|
#include "sysdeps.h" |
22 |
|
|
23 |
– |
#include <gtk/gtk.h> |
23 |
|
#include <stdlib.h> |
24 |
+ |
#include <string.h> |
25 |
+ |
#include <fcntl.h> |
26 |
+ |
#include <sys/stat.h> |
27 |
+ |
#include <gtk/gtk.h> |
28 |
|
|
29 |
|
#include "user_strings.h" |
30 |
|
#include "version.h" |
52 |
|
|
53 |
|
|
54 |
|
/* |
55 |
+ |
* SheepShaver glue |
56 |
+ |
*/ |
57 |
+ |
|
58 |
+ |
#ifdef SHEEPSHAVER |
59 |
+ |
#define DISABLE_SCSI 1 |
60 |
+ |
#define PROGRAM_NAME "SheepShaver" |
61 |
+ |
enum { |
62 |
+ |
STR_WINDOW_LAB = STR_WINDOW_CTRL, |
63 |
+ |
STR_FULLSCREEN_LAB = STR_FULLSCREEN_CTRL, |
64 |
+ |
STR_SERIALA_CTRL = STR_SERPORTA_CTRL, |
65 |
+ |
STR_SERIALB_CTRL = STR_SERPORTB_CTRL, |
66 |
+ |
}; |
67 |
+ |
#else |
68 |
+ |
#define PROGRAM_NAME "BasiliskII" |
69 |
+ |
#endif |
70 |
+ |
|
71 |
+ |
|
72 |
+ |
/* |
73 |
|
* Utility functions |
74 |
|
*/ |
75 |
|
|
323 |
|
return button; |
324 |
|
} |
325 |
|
|
326 |
< |
static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *prefs_item, const combo_desc *options) |
326 |
> |
static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *default_value, GList *glist) |
327 |
|
{ |
328 |
|
GtkWidget *box, *label, *combo; |
308 |
– |
char str[32]; |
329 |
|
|
330 |
|
box = gtk_hbox_new(FALSE, 4); |
331 |
|
gtk_widget_show(box); |
334 |
|
label = gtk_label_new(GetString(label_id)); |
335 |
|
gtk_widget_show(label); |
336 |
|
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); |
317 |
– |
|
318 |
– |
GList *glist = NULL; |
319 |
– |
while (options->label_id) { |
320 |
– |
glist = g_list_append(glist, (void *)GetString(options->label_id)); |
321 |
– |
options++; |
322 |
– |
} |
337 |
|
|
338 |
|
combo = gtk_combo_new(); |
339 |
|
gtk_widget_show(combo); |
340 |
|
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); |
341 |
|
|
342 |
< |
sprintf(str, "%d", PrefsFindInt32(prefs_item)); |
329 |
< |
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); |
342 |
> |
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), default_value); |
343 |
|
gtk_box_pack_start(GTK_BOX(box), combo, TRUE, TRUE, 0); |
344 |
|
|
345 |
|
return combo; |
346 |
|
} |
347 |
|
|
348 |
+ |
static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *default_value, const combo_desc *options) |
349 |
+ |
{ |
350 |
+ |
GList *glist = NULL; |
351 |
+ |
while (options->label_id) { |
352 |
+ |
glist = g_list_append(glist, (void *)GetString(options->label_id)); |
353 |
+ |
options++; |
354 |
+ |
} |
355 |
+ |
|
356 |
+ |
return make_combobox(top, label_id, default_value, glist); |
357 |
+ |
} |
358 |
+ |
|
359 |
|
|
360 |
|
/* |
361 |
|
* Show preferences editor |
411 |
|
|
412 |
|
char str[512]; |
413 |
|
sprintf(str, |
414 |
< |
"Basilisk II\nVersion %d.%d\n\n" |
414 |
> |
PROGRAM_NAME "\nVersion %d.%d\n\n" |
415 |
|
"Copyright (C) 1997-2005 Christian Bauer et al.\n" |
416 |
< |
"E-mail: Christian.Bauer@uni-mainz.de\n" |
417 |
< |
"http://www.uni-mainz.de/~bauec002/B2Main.html\n\n" |
418 |
< |
"Basilisk II comes with ABSOLUTELY NO\n" |
416 |
> |
"E-mail: cb@cebix.net\n" |
417 |
> |
#ifdef SHEEPSHAVER |
418 |
> |
"http://sheepshaver.cebix.net/\n\n" |
419 |
> |
#else |
420 |
> |
"http://basilisk.cebix.net/\n\n" |
421 |
> |
#endif |
422 |
> |
PROGRAM_NAME " comes with ABSOLUTELY NO\n" |
423 |
|
"WARRANTY. This is free software, and\n" |
424 |
|
"you are welcome to redistribute it\n" |
425 |
|
"under the terms of the GNU General\n" |
449 |
|
// Menu item descriptions |
450 |
|
static GtkItemFactoryEntry menu_items[] = { |
451 |
|
{(gchar *)GetString(STR_PREFS_MENU_FILE_GTK), NULL, NULL, 0, "<Branch>"}, |
452 |
< |
{(gchar *)GetString(STR_PREFS_ITEM_START_GTK), NULL, GTK_SIGNAL_FUNC(cb_start), 0, NULL}, |
452 |
> |
{(gchar *)GetString(STR_PREFS_ITEM_START_GTK), "<control>S", GTK_SIGNAL_FUNC(cb_start), 0, NULL}, |
453 |
|
{(gchar *)GetString(STR_PREFS_ITEM_ZAP_PRAM_GTK), NULL, GTK_SIGNAL_FUNC(cb_zap_pram), 0, NULL}, |
454 |
|
{(gchar *)GetString(STR_PREFS_ITEM_SEPL_GTK), NULL, NULL, 0, "<Separator>"}, |
455 |
|
{(gchar *)GetString(STR_PREFS_ITEM_QUIT_GTK), "<control>Q", GTK_SIGNAL_FUNC(cb_quit), 0, NULL}, |
456 |
|
{(gchar *)GetString(STR_HELP_MENU_GTK), NULL, NULL, 0, "<LastBranch>"}, |
457 |
< |
{(gchar *)GetString(STR_HELP_ITEM_ABOUT_GTK), NULL, GTK_SIGNAL_FUNC(cb_about), 0, NULL} |
457 |
> |
{(gchar *)GetString(STR_HELP_ITEM_ABOUT_GTK), "<control>H", GTK_SIGNAL_FUNC(cb_about), 0, NULL} |
458 |
|
}; |
459 |
|
|
460 |
|
bool PrefsEditor(void) |
489 |
|
gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, 0); |
490 |
|
|
491 |
|
create_volumes_pane(notebook); |
492 |
< |
create_scsi_pane(notebook); |
492 |
> |
// create_scsi_pane(notebook); XXX not ready yet (merge scsi_windows.cpp from original B2/Win) |
493 |
|
create_graphics_pane(notebook); |
494 |
|
create_input_pane(notebook); |
495 |
|
create_serial_pane(notebook); |
499 |
|
|
500 |
|
static const opt_desc buttons[] = { |
501 |
|
{STR_START_BUTTON, GTK_SIGNAL_FUNC(cb_start)}, |
474 |
– |
{STR_PREFS_ITEM_ZAP_PRAM, GTK_SIGNAL_FUNC(cb_zap_pram)}, |
475 |
– |
{STR_ABOUT_BUTTON, GTK_SIGNAL_FUNC(cb_about)}, |
502 |
|
{STR_QUIT_BUTTON, GTK_SIGNAL_FUNC(cb_quit)}, |
503 |
|
{0, NULL} |
504 |
|
}; |
515 |
|
* "Volumes" pane |
516 |
|
*/ |
517 |
|
|
518 |
+ |
static GtkWidget *w_enableextfs, *w_extdrives, *w_cdrom_drive; |
519 |
|
static GtkWidget *volume_list; |
520 |
|
static int selected_volume; |
521 |
|
|
522 |
+ |
// Set sensitivity of widgets |
523 |
+ |
static void set_volumes_sensitive(void) |
524 |
+ |
{ |
525 |
+ |
const bool enable_extfs = PrefsFindBool("enableextfs"); |
526 |
+ |
gtk_widget_set_sensitive(w_extdrives, enable_extfs); |
527 |
+ |
const bool no_cdrom = PrefsFindBool("nocdrom"); |
528 |
+ |
gtk_widget_set_sensitive(w_cdrom_drive, !no_cdrom); |
529 |
+ |
} |
530 |
+ |
|
531 |
|
// Volume in list selected |
532 |
|
static void cl_selected(GtkWidget *list, int row, int column) |
533 |
|
{ |
549 |
|
gchar *file = (gchar *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req)); |
550 |
|
|
551 |
|
const gchar *str = gtk_entry_get_text(GTK_ENTRY(assoc->entry)); |
552 |
< |
int size = atoi(str); |
552 |
> |
size_t size = atoi(str) << 20; |
553 |
|
|
554 |
< |
char cmd[1024]; |
555 |
< |
sprintf(cmd, "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", file, size); |
556 |
< |
int ret = system(cmd); |
521 |
< |
if (ret == 0) |
554 |
> |
int fd = _open(file, _O_WRONLY | _O_CREAT | _O_BINARY | _O_TRUNC, _S_IREAD | _S_IWRITE); |
555 |
> |
if (fd >= 0) { |
556 |
> |
if (_chsize(fd, size) == 0) |
557 |
|
gtk_clist_append(GTK_CLIST(volume_list), &file); |
558 |
+ |
_close(fd); |
559 |
+ |
} |
560 |
|
gtk_widget_destroy(GTK_WIDGET(assoc->req)); |
561 |
|
delete assoc; |
562 |
|
} |
605 |
|
static void mn_boot_any(...) {PrefsReplaceInt32("bootdriver", 0);} |
606 |
|
static void mn_boot_cdrom(...) {PrefsReplaceInt32("bootdriver", CDROMRefNum);} |
607 |
|
|
608 |
+ |
// "Enable external file system" button toggled |
609 |
+ |
static void tb_enableextfs(GtkWidget *widget) |
610 |
+ |
{ |
611 |
+ |
PrefsReplaceBool("enableextfs", GTK_TOGGLE_BUTTON(widget)->active); |
612 |
+ |
set_volumes_sensitive(); |
613 |
+ |
} |
614 |
+ |
|
615 |
|
// "No CD-ROM Driver" button toggled |
616 |
|
static void tb_nocdrom(GtkWidget *widget) |
617 |
|
{ |
618 |
|
PrefsReplaceBool("nocdrom", GTK_TOGGLE_BUTTON(widget)->active); |
619 |
+ |
set_volumes_sensitive(); |
620 |
+ |
} |
621 |
+ |
|
622 |
+ |
// Add names of CD-ROM devices |
623 |
+ |
static GList *add_cdrom_names(void) |
624 |
+ |
{ |
625 |
+ |
GList *glist = NULL; |
626 |
+ |
|
627 |
+ |
char rootdir[4] = "X:\\"; |
628 |
+ |
for (char letter = 'C'; letter <= 'Z'; letter++) { |
629 |
+ |
rootdir[0] = letter; |
630 |
+ |
if (GetDriveType(rootdir) == DRIVE_CDROM) |
631 |
+ |
glist = g_list_append(glist, strdup(rootdir)); |
632 |
+ |
} |
633 |
+ |
|
634 |
+ |
return glist; |
635 |
+ |
} |
636 |
+ |
|
637 |
+ |
// "Enable polling" button toggled |
638 |
+ |
static void tb_pollmedia(GtkWidget *widget) |
639 |
+ |
{ |
640 |
+ |
PrefsReplaceBool("pollmedia", GTK_TOGGLE_BUTTON(widget)->active); |
641 |
|
} |
642 |
|
|
643 |
|
// Read settings from widgets and set preferences |
651 |
|
gtk_clist_get_text(GTK_CLIST(volume_list), i, 0, &str); |
652 |
|
PrefsAddString("disk", str); |
653 |
|
} |
654 |
+ |
|
655 |
+ |
const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_cdrom_drive)->entry)); |
656 |
+ |
if (str && strlen(str)) |
657 |
+ |
PrefsReplaceString("cdrom", str); |
658 |
+ |
else |
659 |
+ |
PrefsRemoveItem("cdrom"); |
660 |
+ |
|
661 |
+ |
PrefsReplaceString("extdrives", get_file_entry_path(w_extdrives)); |
662 |
|
} |
663 |
|
|
664 |
|
// Create "Volumes" pane |
707 |
|
menu = make_option_menu(box, STR_BOOTDRIVER_CTRL, options, active); |
708 |
|
|
709 |
|
make_checkbox(box, STR_NOCDROM_CTRL, "nocdrom", GTK_SIGNAL_FUNC(tb_nocdrom)); |
710 |
+ |
|
711 |
+ |
GList *glist = add_cdrom_names(); |
712 |
+ |
str = const_cast<char *>(PrefsFindString("cdrom")); |
713 |
+ |
if (str == NULL) |
714 |
+ |
str = ""; |
715 |
+ |
w_cdrom_drive = make_combobox(box, STR_CDROM_DRIVE_CTRL, str, glist); |
716 |
+ |
|
717 |
+ |
make_checkbox(box, STR_POLLMEDIA_CTRL, "pollmedia", GTK_SIGNAL_FUNC(tb_pollmedia)); |
718 |
+ |
|
719 |
+ |
make_separator(box); |
720 |
+ |
w_enableextfs = make_checkbox(box, STR_EXTFS_ENABLE_CTRL, "enableextfs", GTK_SIGNAL_FUNC(tb_enableextfs)); |
721 |
+ |
w_extdrives = make_file_entry(box, STR_EXTFS_DRIVES_CTRL, "extdrives", true); |
722 |
+ |
|
723 |
+ |
set_volumes_sensitive(); |
724 |
|
} |
725 |
|
|
726 |
|
|
728 |
|
* "JIT Compiler" pane |
729 |
|
*/ |
730 |
|
|
731 |
+ |
#ifndef SHEEPSHAVER |
732 |
|
static GtkWidget *w_jit_fpu; |
733 |
|
static GtkWidget *w_jit_atraps; |
734 |
|
static GtkWidget *w_jit_cache_size; |
735 |
|
static GtkWidget *w_jit_lazy_flush; |
736 |
|
static GtkWidget *w_jit_follow_const_jumps; |
737 |
+ |
#endif |
738 |
|
|
739 |
|
// Set sensitivity of widgets |
740 |
|
static void set_jit_sensitive(void) |
741 |
|
{ |
742 |
+ |
#ifndef SHEEPSHAVER |
743 |
|
const bool jit_enabled = PrefsFindBool("jit"); |
744 |
|
gtk_widget_set_sensitive(w_jit_fpu, jit_enabled); |
745 |
|
gtk_widget_set_sensitive(w_jit_cache_size, jit_enabled); |
746 |
|
gtk_widget_set_sensitive(w_jit_lazy_flush, jit_enabled); |
747 |
|
gtk_widget_set_sensitive(w_jit_follow_const_jumps, jit_enabled); |
748 |
+ |
#endif |
749 |
|
} |
750 |
|
|
751 |
|
// "Use JIT Compiler" button toggled |
756 |
|
} |
757 |
|
|
758 |
|
// "Compile FPU Instructions" button toggled |
759 |
+ |
#ifndef SHEEPSHAVER |
760 |
|
static void tb_jit_fpu(GtkWidget *widget) |
761 |
|
{ |
762 |
|
PrefsReplaceBool("jitfpu", GTK_TOGGLE_BUTTON(widget)->active); |
763 |
|
} |
764 |
+ |
#endif |
765 |
|
|
766 |
|
// "Lazy translation cache invalidation" button toggled |
767 |
+ |
#ifndef SHEEPSHAVER |
768 |
|
static void tb_jit_lazy_flush(GtkWidget *widget) |
769 |
|
{ |
770 |
|
PrefsReplaceBool("jitlazyflush", GTK_TOGGLE_BUTTON(widget)->active); |
771 |
|
} |
772 |
+ |
#endif |
773 |
|
|
774 |
|
// "Translate through constant jumps (inline blocks)" button toggled |
775 |
+ |
#ifndef SHEEPSHAVER |
776 |
|
static void tb_jit_follow_const_jumps(GtkWidget *widget) |
777 |
|
{ |
778 |
|
PrefsReplaceBool("jitinline", GTK_TOGGLE_BUTTON(widget)->active); |
779 |
|
} |
780 |
+ |
#endif |
781 |
|
|
782 |
|
// Read settings from widgets and set preferences |
783 |
|
static void read_jit_settings(void) |
785 |
|
#if USE_JIT |
786 |
|
bool jit_enabled = PrefsFindBool("jit"); |
787 |
|
if (jit_enabled) { |
788 |
+ |
#ifndef SHEEPSHAVER |
789 |
|
const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_jit_cache_size)->entry)); |
790 |
|
PrefsReplaceInt32("jitcachesize", atoi(str)); |
791 |
+ |
#endif |
792 |
|
} |
793 |
|
#endif |
794 |
|
} |
795 |
|
|
796 |
+ |
// "Use built-in 68k DR emulator" button toggled |
797 |
+ |
#ifdef SHEEPSHAVER |
798 |
+ |
static void tb_jit_68k(GtkWidget *widget) |
799 |
+ |
{ |
800 |
+ |
PrefsReplaceBool("jit68k", GTK_TOGGLE_BUTTON(widget)->active); |
801 |
+ |
} |
802 |
+ |
#endif |
803 |
+ |
|
804 |
|
// Create "JIT Compiler" pane |
805 |
|
static void create_jit_pane(GtkWidget *top) |
806 |
|
{ |
811 |
|
box = make_pane(top, STR_JIT_PANE_TITLE); |
812 |
|
make_checkbox(box, STR_JIT_CTRL, "jit", GTK_SIGNAL_FUNC(tb_jit)); |
813 |
|
|
814 |
+ |
#ifndef SHEEPSHAVER |
815 |
|
w_jit_fpu = make_checkbox(box, STR_JIT_FPU_CTRL, "jitfpu", GTK_SIGNAL_FUNC(tb_jit_fpu)); |
816 |
|
|
817 |
|
// Translation cache size |
822 |
|
STR_JIT_CACHE_SIZE_16MB_LAB, |
823 |
|
0 |
824 |
|
}; |
825 |
< |
w_jit_cache_size = make_combobox(box, STR_JIT_CACHE_SIZE_CTRL, "jitcachesize", options); |
825 |
> |
sprintf(str, "%d", PrefsFindInt32("jitcachesize")); |
826 |
> |
w_jit_cache_size = make_combobox(box, STR_JIT_CACHE_SIZE_CTRL, str, options); |
827 |
|
|
828 |
|
// Lazy translation cache invalidation |
829 |
|
w_jit_lazy_flush = make_checkbox(box, STR_JIT_LAZY_CINV_CTRL, "jitlazyflush", GTK_SIGNAL_FUNC(tb_jit_lazy_flush)); |
830 |
|
|
831 |
|
// Follow constant jumps (inline basic blocks) |
832 |
|
w_jit_follow_const_jumps = make_checkbox(box, STR_JIT_FOLLOW_CONST_JUMPS, "jitinline", GTK_SIGNAL_FUNC(tb_jit_follow_const_jumps)); |
833 |
+ |
#endif |
834 |
|
|
835 |
|
set_jit_sensitive(); |
836 |
|
#endif |
837 |
+ |
|
838 |
+ |
#ifdef SHEEPSHAVER |
839 |
+ |
make_checkbox(box, STR_JIT_68K_CTRL, "jit68k", GTK_SIGNAL_FUNC(tb_jit_68k)); |
840 |
+ |
#endif |
841 |
|
} |
842 |
|
|
843 |
|
/* |
849 |
|
// Read settings from widgets and set preferences |
850 |
|
static void read_scsi_settings(void) |
851 |
|
{ |
852 |
+ |
#ifndef DISABLE_SCSI |
853 |
|
for (int id=0; id<7; id++) { |
854 |
|
char prefs_name[32]; |
855 |
|
sprintf(prefs_name, "scsi%d", id); |
859 |
|
else |
860 |
|
PrefsRemoveItem(prefs_name); |
861 |
|
} |
862 |
+ |
#endif |
863 |
|
} |
864 |
|
|
865 |
|
// Create "SCSI" pane |
866 |
|
static void create_scsi_pane(GtkWidget *top) |
867 |
|
{ |
868 |
+ |
#ifndef DISABLE_SCSI |
869 |
|
GtkWidget *box; |
870 |
|
|
871 |
|
box = make_pane(top, STR_SCSI_PANE_TITLE); |
875 |
|
sprintf(prefs_name, "scsi%d", id); |
876 |
|
w_scsi[id] = make_file_entry(box, STR_SCSI_ID_0 + id, prefs_name); |
877 |
|
} |
878 |
+ |
#endif |
879 |
|
} |
880 |
|
|
881 |
|
|
919 |
|
{ |
920 |
|
display_type = DISPLAY_SCREEN; |
921 |
|
hide_show_graphics_widgets(); |
922 |
+ |
PrefsReplaceInt32("frameskip", 1); |
923 |
|
} |
924 |
|
|
925 |
|
// "5 Hz".."60Hz" selected |
931 |
|
static void mn_60hz(...) {PrefsReplaceInt32("frameskip", 1);} |
932 |
|
static void mn_dynamic(...) {PrefsReplaceInt32("frameskip", 0);} |
933 |
|
|
934 |
+ |
// QuickDraw acceleration |
935 |
+ |
#ifdef SHEEPSHAVER |
936 |
+ |
static void tb_gfxaccel(GtkWidget *widget) |
937 |
+ |
{ |
938 |
+ |
PrefsReplaceBool("gfxaccel", GTK_TOGGLE_BUTTON(widget)->active); |
939 |
+ |
} |
940 |
+ |
#endif |
941 |
+ |
|
942 |
|
// Set sensitivity of widgets |
943 |
|
static void set_graphics_sensitive(void) |
944 |
|
{ |
956 |
|
static void parse_graphics_prefs(void) |
957 |
|
{ |
958 |
|
display_type = DISPLAY_WINDOW; |
959 |
+ |
#ifdef SHEEPSHAVER |
960 |
+ |
dis_width = 640; |
961 |
+ |
dis_height = 480; |
962 |
+ |
#else |
963 |
|
dis_width = 512; |
964 |
|
dis_height = 384; |
965 |
+ |
#endif |
966 |
|
|
967 |
|
const char *str = PrefsFindString("screen"); |
968 |
|
if (str) { |
1102 |
|
gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 3, 4, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4); |
1103 |
|
w_display_y = GTK_COMBO(combo)->entry; |
1104 |
|
|
1105 |
+ |
#ifdef SHEEPSHAVER |
1106 |
+ |
make_checkbox(box, STR_GFXACCEL_CTRL, "gfxaccel", GTK_SIGNAL_FUNC(tb_gfxaccel)); |
1107 |
+ |
#endif |
1108 |
+ |
|
1109 |
|
make_separator(box); |
1110 |
|
make_checkbox(box, STR_NOSOUND_CTRL, "nosound", GTK_SIGNAL_FUNC(tb_nosound)); |
1111 |
|
|
1125 |
|
// Set sensitivity of widgets |
1126 |
|
static void set_input_sensitive(void) |
1127 |
|
{ |
1128 |
< |
gtk_widget_set_sensitive(w_keycode_file, PrefsFindBool("keycodes")); |
1128 |
> |
const bool use_keycodes = PrefsFindBool("keycodes"); |
1129 |
> |
gtk_widget_set_sensitive(w_keycode_file, use_keycodes); |
1130 |
> |
gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_keycode_file), "chooser_button")), use_keycodes); |
1131 |
|
gtk_widget_set_sensitive(w_mouse_wheel_lines, PrefsFindInt32("mousewheelmode") == 1); |
1132 |
|
} |
1133 |
|
|
1157 |
|
// Create "Input" pane |
1158 |
|
static void create_input_pane(GtkWidget *top) |
1159 |
|
{ |
1160 |
< |
GtkWidget *box, *hbox, *menu, *label; |
1160 |
> |
GtkWidget *box, *hbox, *menu, *label, *button; |
1161 |
|
GtkObject *adj; |
1162 |
|
|
1163 |
|
box = make_pane(top, STR_INPUT_PANE_TITLE); |
1164 |
|
|
1165 |
|
make_checkbox(box, STR_KEYCODES_CTRL, "keycodes", GTK_SIGNAL_FUNC(tb_keycodes)); |
1166 |
< |
w_keycode_file = make_file_entry(box, STR_KEYCODE_FILE_CTRL, "keycodefile"); |
1166 |
> |
|
1167 |
> |
hbox = gtk_hbox_new(FALSE, 4); |
1168 |
> |
gtk_widget_show(hbox); |
1169 |
> |
gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); |
1170 |
> |
|
1171 |
> |
label = gtk_label_new(GetString(STR_KEYCODES_CTRL)); |
1172 |
> |
gtk_widget_show(label); |
1173 |
> |
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1174 |
> |
|
1175 |
> |
const char *str = PrefsFindString("keycodefile"); |
1176 |
> |
if (str == NULL) |
1177 |
> |
str = ""; |
1178 |
> |
|
1179 |
> |
w_keycode_file = gtk_entry_new(); |
1180 |
> |
gtk_entry_set_text(GTK_ENTRY(w_keycode_file), str); |
1181 |
> |
gtk_widget_show(w_keycode_file); |
1182 |
> |
gtk_box_pack_start(GTK_BOX(hbox), w_keycode_file, TRUE, TRUE, 0); |
1183 |
> |
|
1184 |
> |
button = make_browse_button(w_keycode_file); |
1185 |
> |
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
1186 |
> |
g_object_set_data(G_OBJECT(w_keycode_file), "chooser_button", button); |
1187 |
|
|
1188 |
|
make_separator(box); |
1189 |
|
|
1261 |
|
// Port changed in combo |
1262 |
|
static void cb_serial_port_changed(...) |
1263 |
|
{ |
1105 |
– |
printf("serial port changed\n"); |
1264 |
|
set_serial_sensitive(); |
1265 |
|
} |
1266 |
|
|
1318 |
|
* "Ethernet" pane |
1319 |
|
*/ |
1320 |
|
|
1321 |
< |
static GtkWidget *w_ether, *w_udp_port; |
1321 |
> |
static GtkWidget *w_ether; |
1322 |
> |
static GtkWidget *w_ftp_port_list, *w_tcp_port_list; |
1323 |
> |
static const char s_nat_router[] = "NAT/Router module"; |
1324 |
|
|
1325 |
|
// Set sensitivity of widgets |
1326 |
|
static void set_ethernet_sensitive(void) |
1327 |
|
{ |
1328 |
+ |
const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether)); |
1329 |
+ |
|
1330 |
+ |
bool is_nat_router = strcmp(str, s_nat_router) == 0; |
1331 |
+ |
gtk_widget_set_sensitive(w_ftp_port_list, is_nat_router); |
1332 |
+ |
gtk_widget_set_sensitive(w_tcp_port_list, is_nat_router); |
1333 |
|
} |
1334 |
|
|
1335 |
|
// Read settings from widgets and set preferences |
1336 |
|
static void read_ethernet_settings(void) |
1337 |
|
{ |
1338 |
|
const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether)); |
1339 |
< |
if (str && strlen(str)) |
1340 |
< |
PrefsReplaceString("ether", str); |
1339 |
> |
if (str && strlen(str) > 6 && strncmp(str, "NDIS: ", 6) == 0) |
1340 |
> |
PrefsReplaceString("ether", &str[6]); |
1341 |
|
else |
1342 |
|
PrefsRemoveItem("ether"); |
1343 |
+ |
|
1344 |
+ |
const bool router_enabled = str && strcmp(str, s_nat_router) == 0; |
1345 |
+ |
PrefsReplaceBool("routerenabled", router_enabled); |
1346 |
+ |
if (router_enabled) { |
1347 |
+ |
str = gtk_entry_get_text(GTK_ENTRY(w_ftp_port_list)); |
1348 |
+ |
PrefsReplaceString("ftp_port_list", str); |
1349 |
+ |
str = gtk_entry_get_text(GTK_ENTRY(w_tcp_port_list)); |
1350 |
+ |
PrefsReplaceString("tcp_port", str); |
1351 |
+ |
} |
1352 |
+ |
} |
1353 |
+ |
|
1354 |
+ |
// Ethernet emulation type changed in menulist |
1355 |
+ |
static void cb_ether_changed(...) |
1356 |
+ |
{ |
1357 |
+ |
set_ethernet_sensitive(); |
1358 |
|
} |
1359 |
|
|
1360 |
|
// Add names of ethernet interfaces |
1363 |
|
GList *glist = NULL; |
1364 |
|
|
1365 |
|
// TODO: Get list of all Ethernet interfaces |
1366 |
< |
#ifdef HAVE_SLIRP |
1367 |
< |
static char s_slirp[] = "slirp"; |
1188 |
< |
glist = g_list_append(glist, s_slirp); |
1189 |
< |
#endif |
1190 |
< |
#if 0 |
1191 |
< |
if (glist) |
1192 |
< |
g_list_sort(glist, gl_str_cmp); |
1193 |
< |
else |
1194 |
< |
#endif |
1195 |
< |
glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB)); |
1366 |
> |
glist = g_list_append(glist, (void *)s_nat_router); |
1367 |
> |
glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB)); |
1368 |
|
return glist; |
1369 |
|
} |
1370 |
|
|
1386 |
|
gtk_widget_show(combo); |
1387 |
|
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); |
1388 |
|
const char *str = PrefsFindString("ether"); |
1389 |
< |
if (str == NULL) |
1390 |
< |
str = ""; |
1389 |
> |
if (str == NULL || str[0] == '\0') { |
1390 |
> |
if (PrefsFindBool("routerenabled")) |
1391 |
> |
str = s_nat_router; |
1392 |
> |
else |
1393 |
> |
str = GetString(STR_NONE_LAB); |
1394 |
> |
} |
1395 |
|
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); |
1396 |
|
gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1397 |
|
w_ether = GTK_COMBO(combo)->entry; |
1398 |
+ |
gtk_signal_connect(GTK_OBJECT(w_ether), "changed", GTK_SIGNAL_FUNC(cb_ether_changed), NULL); |
1399 |
+ |
|
1400 |
+ |
sep = gtk_hseparator_new(); |
1401 |
+ |
gtk_widget_show(sep); |
1402 |
+ |
gtk_table_attach(GTK_TABLE(table), sep, 0, 2, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1403 |
+ |
|
1404 |
+ |
label = gtk_label_new(GetString(STR_ETHER_FTP_PORT_LIST_CTRL)); |
1405 |
+ |
gtk_widget_show(label); |
1406 |
+ |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1407 |
+ |
|
1408 |
+ |
entry = gtk_entry_new(); |
1409 |
+ |
str = PrefsFindString("ftp_port_list"); |
1410 |
+ |
if (str == NULL) |
1411 |
+ |
str = ""; |
1412 |
+ |
gtk_entry_set_text(GTK_ENTRY(entry), str); |
1413 |
+ |
gtk_widget_show(entry); |
1414 |
+ |
gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 2, 3, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1415 |
+ |
w_ftp_port_list = entry; |
1416 |
+ |
|
1417 |
+ |
label = gtk_label_new(GetString(STR_ETHER_TCP_PORT_LIST_CTRL)); |
1418 |
+ |
gtk_widget_show(label); |
1419 |
+ |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1420 |
+ |
|
1421 |
+ |
entry = gtk_entry_new(); |
1422 |
+ |
str = PrefsFindString("tcp_port"); |
1423 |
+ |
if (str == NULL) |
1424 |
+ |
str = ""; |
1425 |
+ |
gtk_entry_set_text(GTK_ENTRY(entry), str); |
1426 |
+ |
gtk_widget_show(entry); |
1427 |
+ |
gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1428 |
+ |
w_tcp_port_list = entry; |
1429 |
|
|
1430 |
|
set_ethernet_sensitive(); |
1431 |
|
} |
1438 |
|
static GtkWidget *w_ramsize; |
1439 |
|
static GtkWidget *w_rom_file; |
1440 |
|
|
1441 |
+ |
// Don't use CPU when idle? |
1442 |
+ |
#ifdef SHEEPSHAVER |
1443 |
+ |
static void tb_idlewait(GtkWidget *widget) |
1444 |
+ |
{ |
1445 |
+ |
PrefsReplaceBool("idlewait", GTK_TOGGLE_BUTTON(widget)->active); |
1446 |
+ |
} |
1447 |
+ |
#endif |
1448 |
+ |
|
1449 |
|
// "Ignore SEGV" button toggled |
1450 |
|
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION |
1451 |
|
static void tb_ignoresegv(GtkWidget *widget) |
1488 |
|
table = make_table(box, 2, 5); |
1489 |
|
|
1490 |
|
static const combo_desc options[] = { |
1491 |
+ |
#ifndef SHEEPSHAVER |
1492 |
|
STR_RAMSIZE_2MB_LAB, |
1493 |
+ |
#endif |
1494 |
|
STR_RAMSIZE_4MB_LAB, |
1495 |
|
STR_RAMSIZE_8MB_LAB, |
1496 |
|
STR_RAMSIZE_16MB_LAB, |
1499 |
|
STR_RAMSIZE_128MB_LAB, |
1500 |
|
STR_RAMSIZE_256MB_LAB, |
1501 |
|
STR_RAMSIZE_512MB_LAB, |
1502 |
+ |
#ifndef SHEEPSHAVER |
1503 |
|
STR_RAMSIZE_1024MB_LAB, |
1504 |
+ |
#endif |
1505 |
|
0 |
1506 |
|
}; |
1507 |
|
char default_ramsize[10]; |
1508 |
|
sprintf(default_ramsize, "%d", PrefsFindInt32("ramsize") >> 20); |
1509 |
|
w_ramsize = table_make_combobox(table, 0, STR_RAMSIZE_CTRL, default_ramsize, options); |
1510 |
|
|
1511 |
+ |
#ifndef SHEEPSHAVER |
1512 |
|
static const opt_desc model_options[] = { |
1513 |
|
{STR_MODELID_5_LAB, GTK_SIGNAL_FUNC(mn_modelid_5)}, |
1514 |
|
{STR_MODELID_14_LAB, GTK_SIGNAL_FUNC(mn_modelid_14)}, |
1520 |
|
case 14: active = 1; break; |
1521 |
|
} |
1522 |
|
table_make_option_menu(table, 2, STR_MODELID_CTRL, model_options, active); |
1523 |
+ |
#endif |
1524 |
|
|
1525 |
|
#if EMULATED_68K |
1526 |
|
static const opt_desc cpu_options[] = { |
1547 |
|
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION |
1548 |
|
make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv)); |
1549 |
|
#endif |
1550 |
+ |
|
1551 |
+ |
#ifdef SHEEPSHAVER |
1552 |
+ |
make_checkbox(box, STR_IDLEWAIT_CTRL, "idlewait", GTK_SIGNAL_FUNC(tb_idlewait)); |
1553 |
+ |
#endif |
1554 |
|
} |
1555 |
|
|
1556 |
|
|
1593 |
|
|
1594 |
|
|
1595 |
|
/* |
1596 |
+ |
* Display alerts |
1597 |
+ |
*/ |
1598 |
+ |
|
1599 |
+ |
static void display_alert(int title_id, const char *text, int flags) |
1600 |
+ |
{ |
1601 |
+ |
MessageBox(NULL, text, GetString(title_id), MB_OK | flags); |
1602 |
+ |
} |
1603 |
+ |
|
1604 |
+ |
static void ErrorAlert(const char *text) |
1605 |
+ |
{ |
1606 |
+ |
display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP); |
1607 |
+ |
} |
1608 |
+ |
|
1609 |
+ |
|
1610 |
+ |
/* |
1611 |
|
* Start standalone GUI |
1612 |
|
*/ |
1613 |
|
|
1626 |
|
// Exit preferences |
1627 |
|
PrefsExit(); |
1628 |
|
|
1629 |
< |
// Transfer control to the Basilisk II executable |
1629 |
> |
// Transfer control to the executable |
1630 |
|
if (start) { |
1631 |
< |
printf("Start Basilisk II\n"); |
1631 |
> |
char path[_MAX_PATH]; |
1632 |
> |
bool ok = GetModuleFileName(NULL, path, sizeof(path)) != 0; |
1633 |
> |
if (ok) { |
1634 |
> |
char b2_path[_MAX_PATH]; |
1635 |
> |
char *p = strrchr(path, '\\'); |
1636 |
> |
*++p = '\0'; |
1637 |
> |
SetCurrentDirectory(path); |
1638 |
> |
strcpy(b2_path, path); |
1639 |
> |
strcat(b2_path, PROGRAM_NAME); |
1640 |
> |
strcat(b2_path, ".exe"); |
1641 |
> |
HINSTANCE h = ShellExecute(GetDesktopWindow(), "open", |
1642 |
> |
b2_path, "", path, SW_SHOWNORMAL); |
1643 |
> |
if ((int)h <= 32) |
1644 |
> |
ok = false; |
1645 |
> |
} |
1646 |
> |
if (!ok) { |
1647 |
> |
ErrorAlert("Coult not start " PROGRAM_NAME " executable"); |
1648 |
> |
return 1; |
1649 |
> |
} |
1650 |
|
} |
1651 |
|
|
1652 |
|
return 0; |