32 |
|
#include "xpram.h" |
33 |
|
#include "prefs.h" |
34 |
|
#include "prefs_editor.h" |
35 |
+ |
#include "util_windows.h" |
36 |
+ |
#include "b2ether/inc/b2ether_hl.h" |
37 |
|
|
38 |
|
|
39 |
|
// Global variables |
54 |
|
|
55 |
|
|
56 |
|
/* |
57 |
+ |
* SheepShaver glue |
58 |
+ |
*/ |
59 |
+ |
|
60 |
+ |
#ifdef SHEEPSHAVER |
61 |
+ |
#define DISABLE_SCSI 1 |
62 |
+ |
#define PROGRAM_NAME "SheepShaver" |
63 |
+ |
enum { |
64 |
+ |
STR_WINDOW_LAB = STR_WINDOW_CTRL, |
65 |
+ |
STR_FULLSCREEN_LAB = STR_FULLSCREEN_CTRL, |
66 |
+ |
STR_SERIALA_CTRL = STR_SERPORTA_CTRL, |
67 |
+ |
STR_SERIALB_CTRL = STR_SERPORTB_CTRL, |
68 |
+ |
}; |
69 |
+ |
#else |
70 |
+ |
#define DISABLE_SCSI 1 /* XXX merge code from original Basilisk II for Windows */ |
71 |
+ |
#define PROGRAM_NAME "BasiliskII" |
72 |
+ |
#endif |
73 |
+ |
|
74 |
+ |
|
75 |
+ |
/* |
76 |
|
* Utility functions |
77 |
|
*/ |
78 |
|
|
118 |
|
return button; |
119 |
|
} |
120 |
|
|
121 |
< |
static void add_menu_item(GtkWidget *menu, int label_id, GtkSignalFunc func) |
121 |
> |
static void add_menu_item(GtkWidget *menu, const char *label, GtkSignalFunc func, gpointer data = NULL) |
122 |
|
{ |
123 |
< |
GtkWidget *item = gtk_menu_item_new_with_label(GetString(label_id)); |
123 |
> |
GtkWidget *item = gtk_menu_item_new_with_label(label); |
124 |
|
gtk_widget_show(item); |
125 |
< |
gtk_signal_connect(GTK_OBJECT(item), "activate", func, NULL); |
125 |
> |
gtk_signal_connect(GTK_OBJECT(item), "activate", func, data); |
126 |
|
gtk_menu_append(GTK_MENU(menu), item); |
127 |
|
} |
128 |
|
|
129 |
+ |
static void add_menu_item(GtkWidget *menu, int label_id, GtkSignalFunc func) |
130 |
+ |
{ |
131 |
+ |
add_menu_item(menu, GetString(label_id), func, NULL); |
132 |
+ |
} |
133 |
+ |
|
134 |
|
static GtkWidget *make_pane(GtkWidget *notebook, int title_id) |
135 |
|
{ |
136 |
|
GtkWidget *frame, *label, *box; |
331 |
|
return button; |
332 |
|
} |
333 |
|
|
334 |
< |
static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *prefs_item, const combo_desc *options) |
334 |
> |
static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *default_value, GList *glist) |
335 |
|
{ |
336 |
|
GtkWidget *box, *label, *combo; |
311 |
– |
char str[32]; |
337 |
|
|
338 |
|
box = gtk_hbox_new(FALSE, 4); |
339 |
|
gtk_widget_show(box); |
342 |
|
label = gtk_label_new(GetString(label_id)); |
343 |
|
gtk_widget_show(label); |
344 |
|
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); |
320 |
– |
|
321 |
– |
GList *glist = NULL; |
322 |
– |
while (options->label_id) { |
323 |
– |
glist = g_list_append(glist, (void *)GetString(options->label_id)); |
324 |
– |
options++; |
325 |
– |
} |
345 |
|
|
346 |
|
combo = gtk_combo_new(); |
347 |
|
gtk_widget_show(combo); |
348 |
|
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); |
349 |
|
|
350 |
< |
sprintf(str, "%d", PrefsFindInt32(prefs_item)); |
332 |
< |
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); |
350 |
> |
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), default_value); |
351 |
|
gtk_box_pack_start(GTK_BOX(box), combo, TRUE, TRUE, 0); |
352 |
|
|
353 |
|
return combo; |
354 |
|
} |
355 |
|
|
356 |
+ |
static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *default_value, const combo_desc *options) |
357 |
+ |
{ |
358 |
+ |
GList *glist = NULL; |
359 |
+ |
while (options->label_id) { |
360 |
+ |
glist = g_list_append(glist, (void *)GetString(options->label_id)); |
361 |
+ |
options++; |
362 |
+ |
} |
363 |
+ |
|
364 |
+ |
return make_combobox(top, label_id, default_value, glist); |
365 |
+ |
} |
366 |
+ |
|
367 |
|
|
368 |
|
/* |
369 |
|
* Show preferences editor |
419 |
|
|
420 |
|
char str[512]; |
421 |
|
sprintf(str, |
422 |
< |
"Basilisk II\nVersion %d.%d\n\n" |
422 |
> |
PROGRAM_NAME "\nVersion %d.%d\n\n" |
423 |
|
"Copyright (C) 1997-2005 Christian Bauer et al.\n" |
424 |
< |
"E-mail: Christian.Bauer@uni-mainz.de\n" |
425 |
< |
"http://www.uni-mainz.de/~bauec002/B2Main.html\n\n" |
426 |
< |
"Basilisk II comes with ABSOLUTELY NO\n" |
424 |
> |
"E-mail: cb@cebix.net\n" |
425 |
> |
#ifdef SHEEPSHAVER |
426 |
> |
"http://sheepshaver.cebix.net/\n\n" |
427 |
> |
#else |
428 |
> |
"http://basilisk.cebix.net/\n\n" |
429 |
> |
#endif |
430 |
> |
PROGRAM_NAME " comes with ABSOLUTELY NO\n" |
431 |
|
"WARRANTY. This is free software, and\n" |
432 |
|
"you are welcome to redistribute it\n" |
433 |
|
"under the terms of the GNU General\n" |
465 |
|
{(gchar *)GetString(STR_HELP_ITEM_ABOUT_GTK), "<control>H", GTK_SIGNAL_FUNC(cb_about), 0, NULL} |
466 |
|
}; |
467 |
|
|
468 |
+ |
void PrefsMigrate(void) |
469 |
+ |
{ |
470 |
+ |
// Ethernet |
471 |
+ |
const char *ether = PrefsFindString("ether"); |
472 |
+ |
if (ether && ether[0] == '{') { |
473 |
+ |
PrefsReplaceString("etherguid", ether); |
474 |
+ |
PrefsReplaceString("ether", "b2ether"); |
475 |
+ |
} |
476 |
+ |
if (PrefsFindBool("routerenabled")) { |
477 |
+ |
PrefsRemoveItem("etherguid"); |
478 |
+ |
PrefsReplaceString("ether", "router"); |
479 |
+ |
} |
480 |
+ |
} |
481 |
+ |
|
482 |
|
bool PrefsEditor(void) |
483 |
|
{ |
484 |
|
// Create window |
511 |
|
gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, 0); |
512 |
|
|
513 |
|
create_volumes_pane(notebook); |
514 |
< |
// create_scsi_pane(notebook); XXX not ready yet (merge scsi_windows.cpp from original B2/Win) |
514 |
> |
#ifndef DISABLE_SCSI |
515 |
> |
create_scsi_pane(notebook); |
516 |
> |
#endif |
517 |
|
create_graphics_pane(notebook); |
518 |
|
create_input_pane(notebook); |
519 |
|
create_serial_pane(notebook); |
539 |
|
* "Volumes" pane |
540 |
|
*/ |
541 |
|
|
542 |
< |
static GtkWidget *w_enableextfs, *w_extdrives; |
542 |
> |
static GtkWidget *w_enableextfs, *w_extdrives, *w_cdrom_drive; |
543 |
|
static GtkWidget *volume_list; |
544 |
|
static int selected_volume; |
545 |
|
|
548 |
|
{ |
549 |
|
const bool enable_extfs = PrefsFindBool("enableextfs"); |
550 |
|
gtk_widget_set_sensitive(w_extdrives, enable_extfs); |
551 |
+ |
const bool no_cdrom = PrefsFindBool("nocdrom"); |
552 |
+ |
gtk_widget_set_sensitive(w_cdrom_drive, !no_cdrom); |
553 |
|
} |
554 |
|
|
555 |
|
// Volume in list selected |
640 |
|
static void tb_nocdrom(GtkWidget *widget) |
641 |
|
{ |
642 |
|
PrefsReplaceBool("nocdrom", GTK_TOGGLE_BUTTON(widget)->active); |
643 |
+ |
set_volumes_sensitive(); |
644 |
+ |
} |
645 |
+ |
|
646 |
+ |
// Add names of CD-ROM devices |
647 |
+ |
static GList *add_cdrom_names(void) |
648 |
+ |
{ |
649 |
+ |
GList *glist = NULL; |
650 |
+ |
|
651 |
+ |
char rootdir[4] = "X:\\"; |
652 |
+ |
for (char letter = 'C'; letter <= 'Z'; letter++) { |
653 |
+ |
rootdir[0] = letter; |
654 |
+ |
if (GetDriveType(rootdir) == DRIVE_CDROM) |
655 |
+ |
glist = g_list_append(glist, strdup(rootdir)); |
656 |
+ |
} |
657 |
+ |
|
658 |
+ |
return glist; |
659 |
|
} |
660 |
|
|
661 |
|
// "Enable polling" button toggled |
676 |
|
PrefsAddString("disk", str); |
677 |
|
} |
678 |
|
|
679 |
+ |
const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_cdrom_drive)->entry)); |
680 |
+ |
if (str && strlen(str)) |
681 |
+ |
PrefsReplaceString("cdrom", str); |
682 |
+ |
else |
683 |
+ |
PrefsRemoveItem("cdrom"); |
684 |
+ |
|
685 |
|
PrefsReplaceString("extdrives", get_file_entry_path(w_extdrives)); |
686 |
|
} |
687 |
|
|
732 |
|
|
733 |
|
make_checkbox(box, STR_NOCDROM_CTRL, "nocdrom", GTK_SIGNAL_FUNC(tb_nocdrom)); |
734 |
|
|
735 |
+ |
GList *glist = add_cdrom_names(); |
736 |
+ |
str = const_cast<char *>(PrefsFindString("cdrom")); |
737 |
+ |
if (str == NULL) |
738 |
+ |
str = ""; |
739 |
+ |
w_cdrom_drive = make_combobox(box, STR_CDROM_DRIVE_CTRL, str, glist); |
740 |
+ |
|
741 |
|
make_checkbox(box, STR_POLLMEDIA_CTRL, "pollmedia", GTK_SIGNAL_FUNC(tb_pollmedia)); |
742 |
|
|
743 |
|
make_separator(box); |
752 |
|
* "JIT Compiler" pane |
753 |
|
*/ |
754 |
|
|
755 |
+ |
#ifndef SHEEPSHAVER |
756 |
|
static GtkWidget *w_jit_fpu; |
757 |
|
static GtkWidget *w_jit_atraps; |
758 |
|
static GtkWidget *w_jit_cache_size; |
759 |
|
static GtkWidget *w_jit_lazy_flush; |
760 |
|
static GtkWidget *w_jit_follow_const_jumps; |
761 |
+ |
#endif |
762 |
|
|
763 |
|
// Set sensitivity of widgets |
764 |
|
static void set_jit_sensitive(void) |
765 |
|
{ |
766 |
+ |
#ifndef SHEEPSHAVER |
767 |
|
const bool jit_enabled = PrefsFindBool("jit"); |
768 |
|
gtk_widget_set_sensitive(w_jit_fpu, jit_enabled); |
769 |
|
gtk_widget_set_sensitive(w_jit_cache_size, jit_enabled); |
770 |
|
gtk_widget_set_sensitive(w_jit_lazy_flush, jit_enabled); |
771 |
|
gtk_widget_set_sensitive(w_jit_follow_const_jumps, jit_enabled); |
772 |
+ |
#endif |
773 |
|
} |
774 |
|
|
775 |
|
// "Use JIT Compiler" button toggled |
780 |
|
} |
781 |
|
|
782 |
|
// "Compile FPU Instructions" button toggled |
783 |
+ |
#ifndef SHEEPSHAVER |
784 |
|
static void tb_jit_fpu(GtkWidget *widget) |
785 |
|
{ |
786 |
|
PrefsReplaceBool("jitfpu", GTK_TOGGLE_BUTTON(widget)->active); |
787 |
|
} |
788 |
+ |
#endif |
789 |
|
|
790 |
|
// "Lazy translation cache invalidation" button toggled |
791 |
+ |
#ifndef SHEEPSHAVER |
792 |
|
static void tb_jit_lazy_flush(GtkWidget *widget) |
793 |
|
{ |
794 |
|
PrefsReplaceBool("jitlazyflush", GTK_TOGGLE_BUTTON(widget)->active); |
795 |
|
} |
796 |
+ |
#endif |
797 |
|
|
798 |
|
// "Translate through constant jumps (inline blocks)" button toggled |
799 |
+ |
#ifndef SHEEPSHAVER |
800 |
|
static void tb_jit_follow_const_jumps(GtkWidget *widget) |
801 |
|
{ |
802 |
|
PrefsReplaceBool("jitinline", GTK_TOGGLE_BUTTON(widget)->active); |
803 |
|
} |
804 |
+ |
#endif |
805 |
|
|
806 |
|
// Read settings from widgets and set preferences |
807 |
|
static void read_jit_settings(void) |
809 |
|
#if USE_JIT |
810 |
|
bool jit_enabled = PrefsFindBool("jit"); |
811 |
|
if (jit_enabled) { |
812 |
+ |
#ifndef SHEEPSHAVER |
813 |
|
const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_jit_cache_size)->entry)); |
814 |
|
PrefsReplaceInt32("jitcachesize", atoi(str)); |
815 |
+ |
#endif |
816 |
|
} |
817 |
|
#endif |
818 |
|
} |
819 |
|
|
820 |
+ |
// "Use built-in 68k DR emulator" button toggled |
821 |
+ |
#ifdef SHEEPSHAVER |
822 |
+ |
static void tb_jit_68k(GtkWidget *widget) |
823 |
+ |
{ |
824 |
+ |
PrefsReplaceBool("jit68k", GTK_TOGGLE_BUTTON(widget)->active); |
825 |
+ |
} |
826 |
+ |
#endif |
827 |
+ |
|
828 |
|
// Create "JIT Compiler" pane |
829 |
|
static void create_jit_pane(GtkWidget *top) |
830 |
|
{ |
835 |
|
box = make_pane(top, STR_JIT_PANE_TITLE); |
836 |
|
make_checkbox(box, STR_JIT_CTRL, "jit", GTK_SIGNAL_FUNC(tb_jit)); |
837 |
|
|
838 |
+ |
#ifndef SHEEPSHAVER |
839 |
|
w_jit_fpu = make_checkbox(box, STR_JIT_FPU_CTRL, "jitfpu", GTK_SIGNAL_FUNC(tb_jit_fpu)); |
840 |
|
|
841 |
|
// Translation cache size |
846 |
|
STR_JIT_CACHE_SIZE_16MB_LAB, |
847 |
|
0 |
848 |
|
}; |
849 |
< |
w_jit_cache_size = make_combobox(box, STR_JIT_CACHE_SIZE_CTRL, "jitcachesize", options); |
849 |
> |
sprintf(str, "%d", PrefsFindInt32("jitcachesize")); |
850 |
> |
w_jit_cache_size = make_combobox(box, STR_JIT_CACHE_SIZE_CTRL, str, options); |
851 |
|
|
852 |
|
// Lazy translation cache invalidation |
853 |
|
w_jit_lazy_flush = make_checkbox(box, STR_JIT_LAZY_CINV_CTRL, "jitlazyflush", GTK_SIGNAL_FUNC(tb_jit_lazy_flush)); |
854 |
|
|
855 |
|
// Follow constant jumps (inline basic blocks) |
856 |
|
w_jit_follow_const_jumps = make_checkbox(box, STR_JIT_FOLLOW_CONST_JUMPS, "jitinline", GTK_SIGNAL_FUNC(tb_jit_follow_const_jumps)); |
857 |
+ |
#endif |
858 |
|
|
859 |
|
set_jit_sensitive(); |
860 |
|
#endif |
861 |
+ |
|
862 |
+ |
#ifdef SHEEPSHAVER |
863 |
+ |
make_checkbox(box, STR_JIT_68K_CTRL, "jit68k", GTK_SIGNAL_FUNC(tb_jit_68k)); |
864 |
+ |
#endif |
865 |
|
} |
866 |
|
|
867 |
|
/* |
873 |
|
// Read settings from widgets and set preferences |
874 |
|
static void read_scsi_settings(void) |
875 |
|
{ |
876 |
+ |
#ifndef DISABLE_SCSI |
877 |
|
for (int id=0; id<7; id++) { |
878 |
|
char prefs_name[32]; |
879 |
|
sprintf(prefs_name, "scsi%d", id); |
883 |
|
else |
884 |
|
PrefsRemoveItem(prefs_name); |
885 |
|
} |
886 |
+ |
#endif |
887 |
|
} |
888 |
|
|
889 |
|
// Create "SCSI" pane |
890 |
|
static void create_scsi_pane(GtkWidget *top) |
891 |
|
{ |
892 |
+ |
#ifndef DISABLE_SCSI |
893 |
|
GtkWidget *box; |
894 |
|
|
895 |
|
box = make_pane(top, STR_SCSI_PANE_TITLE); |
899 |
|
sprintf(prefs_name, "scsi%d", id); |
900 |
|
w_scsi[id] = make_file_entry(box, STR_SCSI_ID_0 + id, prefs_name); |
901 |
|
} |
902 |
+ |
#endif |
903 |
|
} |
904 |
|
|
905 |
|
|
943 |
|
{ |
944 |
|
display_type = DISPLAY_SCREEN; |
945 |
|
hide_show_graphics_widgets(); |
946 |
+ |
PrefsReplaceInt32("frameskip", 1); |
947 |
|
} |
948 |
|
|
949 |
|
// "5 Hz".."60Hz" selected |
955 |
|
static void mn_60hz(...) {PrefsReplaceInt32("frameskip", 1);} |
956 |
|
static void mn_dynamic(...) {PrefsReplaceInt32("frameskip", 0);} |
957 |
|
|
958 |
+ |
// QuickDraw acceleration |
959 |
+ |
#ifdef SHEEPSHAVER |
960 |
+ |
static void tb_gfxaccel(GtkWidget *widget) |
961 |
+ |
{ |
962 |
+ |
PrefsReplaceBool("gfxaccel", GTK_TOGGLE_BUTTON(widget)->active); |
963 |
+ |
} |
964 |
+ |
#endif |
965 |
+ |
|
966 |
|
// Set sensitivity of widgets |
967 |
|
static void set_graphics_sensitive(void) |
968 |
|
{ |
980 |
|
static void parse_graphics_prefs(void) |
981 |
|
{ |
982 |
|
display_type = DISPLAY_WINDOW; |
983 |
+ |
#ifdef SHEEPSHAVER |
984 |
+ |
dis_width = 640; |
985 |
+ |
dis_height = 480; |
986 |
+ |
#else |
987 |
|
dis_width = 512; |
988 |
|
dis_height = 384; |
989 |
+ |
#endif |
990 |
|
|
991 |
|
const char *str = PrefsFindString("screen"); |
992 |
|
if (str) { |
1126 |
|
gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 3, 4, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4); |
1127 |
|
w_display_y = GTK_COMBO(combo)->entry; |
1128 |
|
|
1129 |
+ |
#ifdef SHEEPSHAVER |
1130 |
+ |
make_checkbox(box, STR_GFXACCEL_CTRL, "gfxaccel", GTK_SIGNAL_FUNC(tb_gfxaccel)); |
1131 |
+ |
#endif |
1132 |
+ |
|
1133 |
|
make_separator(box); |
1134 |
|
make_checkbox(box, STR_NOSOUND_CTRL, "nosound", GTK_SIGNAL_FUNC(tb_nosound)); |
1135 |
|
|
1342 |
|
* "Ethernet" pane |
1343 |
|
*/ |
1344 |
|
|
1217 |
– |
static GtkWidget *w_ether; |
1345 |
|
static GtkWidget *w_ftp_port_list, *w_tcp_port_list; |
1219 |
– |
static const char s_nat_router[] = "NAT/Router module"; |
1346 |
|
|
1347 |
|
// Set sensitivity of widgets |
1348 |
|
static void set_ethernet_sensitive(void) |
1349 |
|
{ |
1350 |
< |
const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether)); |
1350 |
> |
const char *str = PrefsFindString("ether"); |
1351 |
|
|
1352 |
< |
bool is_nat_router = strcmp(str, s_nat_router) == 0; |
1353 |
< |
gtk_widget_set_sensitive(w_ftp_port_list, is_nat_router); |
1354 |
< |
gtk_widget_set_sensitive(w_tcp_port_list, is_nat_router); |
1352 |
> |
bool is_router = str && strcmp(str, "router") == 0; |
1353 |
> |
gtk_widget_set_sensitive(w_ftp_port_list, is_router); |
1354 |
> |
gtk_widget_set_sensitive(w_tcp_port_list, is_router); |
1355 |
|
} |
1356 |
|
|
1357 |
|
// Read settings from widgets and set preferences |
1358 |
|
static void read_ethernet_settings(void) |
1359 |
|
{ |
1360 |
< |
const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether)); |
1235 |
< |
if (str && strlen(str) > 6 && strncmp(str, "NDIS: ", 6) == 0) |
1236 |
< |
PrefsReplaceString("ether", &str[6]); |
1237 |
< |
else |
1238 |
< |
PrefsRemoveItem("ether"); |
1360 |
> |
const char *str = PrefsFindString("ether"); |
1361 |
|
|
1362 |
< |
const bool router_enabled = str && strcmp(str, s_nat_router) == 0; |
1363 |
< |
PrefsReplaceBool("routerenabled", router_enabled); |
1242 |
< |
if (router_enabled) { |
1362 |
> |
bool is_router = str && strcmp(str, "router") == 0; |
1363 |
> |
if (is_router) { |
1364 |
|
str = gtk_entry_get_text(GTK_ENTRY(w_ftp_port_list)); |
1365 |
|
PrefsReplaceString("ftp_port_list", str); |
1366 |
|
str = gtk_entry_get_text(GTK_ENTRY(w_tcp_port_list)); |
1374 |
|
set_ethernet_sensitive(); |
1375 |
|
} |
1376 |
|
|
1377 |
< |
// Add names of ethernet interfaces |
1378 |
< |
static GList *add_ether_names(void) |
1377 |
> |
// Ethernet option "None" selected |
1378 |
> |
static void mn_ether_none(void) |
1379 |
|
{ |
1380 |
< |
GList *glist = NULL; |
1381 |
< |
|
1261 |
< |
// TODO: Get list of all Ethernet interfaces |
1262 |
< |
#ifdef HAVE_SLIRP |
1263 |
< |
static const char s_slirp[] = "slirp"; |
1264 |
< |
glist = g_list_append(glist, (void *)s_slirp); |
1265 |
< |
#endif |
1266 |
< |
glist = g_list_append(glist, (void *)s_nat_router); |
1267 |
< |
glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB)); |
1268 |
< |
return glist; |
1380 |
> |
PrefsRemoveItem("ether"); |
1381 |
> |
PrefsRemoveItem("etherguid"); |
1382 |
|
} |
1383 |
|
|
1384 |
+ |
// Ethernet option "Basilisk II Router" selected |
1385 |
+ |
static void mn_ether_router(void) |
1386 |
+ |
{ |
1387 |
+ |
PrefsReplaceString("ether", "router"); |
1388 |
+ |
PrefsRemoveItem("etherguid"); |
1389 |
+ |
} |
1390 |
+ |
|
1391 |
+ |
// Ethernet option "Basilisk II Slirp" selected |
1392 |
+ |
static void mn_ether_slirp(void) |
1393 |
+ |
{ |
1394 |
+ |
PrefsReplaceString("ether", "slirp"); |
1395 |
+ |
PrefsRemoveItem("etherguid"); |
1396 |
+ |
} |
1397 |
+ |
|
1398 |
+ |
// Ethernet option for Basilisk II driver selected |
1399 |
+ |
static void mn_ether_b2ether(GtkWidget *, const char *guid) |
1400 |
+ |
{ |
1401 |
+ |
PrefsReplaceString("ether", "b2ether"); |
1402 |
+ |
PrefsReplaceString("etherguid", guid); |
1403 |
+ |
} |
1404 |
+ |
|
1405 |
+ |
// Ethernet option for Basilisk II driver selected |
1406 |
+ |
static void mn_ether_tap(GtkWidget *, const char *guid) |
1407 |
+ |
{ |
1408 |
+ |
PrefsReplaceString("ether", "tap"); |
1409 |
+ |
PrefsReplaceString("etherguid", guid); |
1410 |
+ |
} |
1411 |
+ |
|
1412 |
+ |
// Create ethernet interfaces menu |
1413 |
+ |
static int create_ether_menu(GtkWidget *menu) |
1414 |
+ |
{ |
1415 |
+ |
int active = -1; |
1416 |
+ |
int n_items = 0; |
1417 |
+ |
const char *ether = PrefsFindString("ether"); |
1418 |
+ |
const char *etherguid = PrefsFindString("etherguid"); |
1419 |
+ |
|
1420 |
+ |
// No Ethernet |
1421 |
+ |
add_menu_item(menu, STR_NONE_LAB, (GtkSignalFunc)mn_ether_none); |
1422 |
+ |
if (ether == NULL) |
1423 |
+ |
active = n_items; |
1424 |
+ |
n_items++; |
1425 |
+ |
|
1426 |
+ |
// Basilisk II Router |
1427 |
+ |
add_menu_item(menu, "Basilisk II Router", (GtkSignalFunc)mn_ether_router); |
1428 |
+ |
if (ether && strcmp(ether, "router") == 0) |
1429 |
+ |
active = n_items; |
1430 |
+ |
n_items++; |
1431 |
+ |
|
1432 |
+ |
// Basilisk II Slirp |
1433 |
+ |
add_menu_item(menu, "Basilisk II Slirp", (GtkSignalFunc)mn_ether_slirp); |
1434 |
+ |
if (ether && strcmp(ether, "slirp") == 0) |
1435 |
+ |
active = n_items; |
1436 |
+ |
n_items++; |
1437 |
+ |
|
1438 |
+ |
// Basilisk II Ethernet Adapter |
1439 |
+ |
PacketOpenAdapter("", 0); |
1440 |
+ |
{ |
1441 |
+ |
ULONG sz; |
1442 |
+ |
char names[1024]; |
1443 |
+ |
sz = sizeof(names); |
1444 |
+ |
if (PacketGetAdapterNames(NULL, names, &sz) == ERROR_SUCCESS) { |
1445 |
+ |
char *p = names; |
1446 |
+ |
while (*p) { |
1447 |
+ |
const char DEVICE_HEADER[] = "\\Device\\B2ether_"; |
1448 |
+ |
if (strnicmp(p, DEVICE_HEADER, sizeof(DEVICE_HEADER) - 1) == 0) { |
1449 |
+ |
LPADAPTER fd = PacketOpenAdapter(p + sizeof(DEVICE_HEADER) - 1, 0); |
1450 |
+ |
if (fd) { |
1451 |
+ |
char guid[256]; |
1452 |
+ |
sprintf(guid, "%s", p + sizeof(DEVICE_HEADER) - 1); |
1453 |
+ |
const char *name = ether_guid_to_name(guid); |
1454 |
+ |
if (name && (name = g_locale_to_utf8(name, -1, NULL, NULL, NULL))) { |
1455 |
+ |
add_menu_item(menu, name, (GtkSignalFunc)mn_ether_b2ether, strdup(guid)); |
1456 |
+ |
if (etherguid && strcmp(guid, etherguid) == 0 && |
1457 |
+ |
ether && strcmp(ether, "b2ether") == 0) |
1458 |
+ |
active = n_items; |
1459 |
+ |
n_items++; |
1460 |
+ |
} |
1461 |
+ |
PacketCloseAdapter(fd); |
1462 |
+ |
} |
1463 |
+ |
} |
1464 |
+ |
p += strlen(p) + 1; |
1465 |
+ |
} |
1466 |
+ |
} |
1467 |
+ |
} |
1468 |
+ |
PacketCloseAdapter(NULL); |
1469 |
+ |
|
1470 |
+ |
// TAP-Win32 |
1471 |
+ |
const char *tap_devices; |
1472 |
+ |
if ((tap_devices = ether_tap_devices()) != NULL) { |
1473 |
+ |
const char *guid = tap_devices; |
1474 |
+ |
while (*guid) { |
1475 |
+ |
const char *name = ether_guid_to_name(guid); |
1476 |
+ |
if (name && (name = g_locale_to_utf8(name, -1, NULL, NULL, NULL))) { |
1477 |
+ |
add_menu_item(menu, name, (GtkSignalFunc)mn_ether_tap, strdup(guid)); |
1478 |
+ |
if (etherguid && strcmp(guid, etherguid) == 0 && |
1479 |
+ |
ether && strcmp(ether, "tap") == 0) |
1480 |
+ |
active = n_items; |
1481 |
+ |
n_items++; |
1482 |
+ |
} |
1483 |
+ |
guid += strlen(guid) + 1; |
1484 |
+ |
} |
1485 |
+ |
free((char *)tap_devices); |
1486 |
+ |
} |
1487 |
+ |
|
1488 |
+ |
return active; |
1489 |
+ |
} |
1490 |
|
|
1491 |
|
// Create "Ethernet" pane |
1492 |
|
static void create_ethernet_pane(GtkWidget *top) |
1493 |
|
{ |
1494 |
< |
GtkWidget *box, *hbox, *table, *label, *combo, *sep, *entry; |
1494 |
> |
GtkWidget *box, *hbox, *table, *label, *sep, *entry, *opt, *menu, *item; |
1495 |
|
|
1496 |
|
box = make_pane(top, STR_NETWORK_PANE_TITLE); |
1497 |
|
table = make_table(box, 2, 5); |
1500 |
|
gtk_widget_show(label); |
1501 |
|
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1502 |
|
|
1503 |
< |
GList *glist = add_ether_names(); |
1504 |
< |
combo = gtk_combo_new(); |
1505 |
< |
gtk_widget_show(combo); |
1506 |
< |
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); |
1507 |
< |
const char *str = PrefsFindString("ether"); |
1508 |
< |
if (str == NULL || str[0] == '\0') { |
1509 |
< |
if (PrefsFindBool("routerenabled")) |
1510 |
< |
str = s_nat_router; |
1511 |
< |
else |
1293 |
< |
str = GetString(STR_NONE_LAB); |
1294 |
< |
} |
1295 |
< |
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); |
1296 |
< |
gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1297 |
< |
w_ether = GTK_COMBO(combo)->entry; |
1298 |
< |
gtk_signal_connect(GTK_OBJECT(w_ether), "changed", GTK_SIGNAL_FUNC(cb_ether_changed), NULL); |
1503 |
> |
opt = gtk_option_menu_new(); |
1504 |
> |
gtk_widget_show(opt); |
1505 |
> |
menu = gtk_menu_new(); |
1506 |
> |
int active = create_ether_menu(menu); |
1507 |
> |
if (active >= 0) |
1508 |
> |
gtk_menu_set_active(GTK_MENU(menu), active); |
1509 |
> |
gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu); |
1510 |
> |
gtk_table_attach(GTK_TABLE(table), opt, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1511 |
> |
gtk_signal_connect(GTK_OBJECT(opt), "changed", GTK_SIGNAL_FUNC(cb_ether_changed), NULL); |
1512 |
|
|
1513 |
|
sep = gtk_hseparator_new(); |
1514 |
|
gtk_widget_show(sep); |
1519 |
|
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1520 |
|
|
1521 |
|
entry = gtk_entry_new(); |
1522 |
< |
str = PrefsFindString("ftp_port_list"); |
1522 |
> |
const char *str = PrefsFindString("ftp_port_list"); |
1523 |
|
if (str == NULL) |
1524 |
|
str = ""; |
1525 |
|
gtk_entry_set_text(GTK_ENTRY(entry), str); |
1551 |
|
static GtkWidget *w_ramsize; |
1552 |
|
static GtkWidget *w_rom_file; |
1553 |
|
|
1554 |
+ |
// Don't use CPU when idle? |
1555 |
+ |
static void tb_idlewait(GtkWidget *widget) |
1556 |
+ |
{ |
1557 |
+ |
PrefsReplaceBool("idlewait", GTK_TOGGLE_BUTTON(widget)->active); |
1558 |
+ |
} |
1559 |
+ |
|
1560 |
|
// "Ignore SEGV" button toggled |
1561 |
|
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION |
1562 |
|
static void tb_ignoresegv(GtkWidget *widget) |
1599 |
|
table = make_table(box, 2, 5); |
1600 |
|
|
1601 |
|
static const combo_desc options[] = { |
1602 |
+ |
#ifndef SHEEPSHAVER |
1603 |
|
STR_RAMSIZE_2MB_LAB, |
1604 |
+ |
#endif |
1605 |
|
STR_RAMSIZE_4MB_LAB, |
1606 |
|
STR_RAMSIZE_8MB_LAB, |
1607 |
|
STR_RAMSIZE_16MB_LAB, |
1613 |
|
STR_RAMSIZE_1024MB_LAB, |
1614 |
|
0 |
1615 |
|
}; |
1616 |
< |
char default_ramsize[10]; |
1616 |
> |
char default_ramsize[16]; |
1617 |
|
sprintf(default_ramsize, "%d", PrefsFindInt32("ramsize") >> 20); |
1618 |
|
w_ramsize = table_make_combobox(table, 0, STR_RAMSIZE_CTRL, default_ramsize, options); |
1619 |
|
|
1620 |
+ |
#ifndef SHEEPSHAVER |
1621 |
|
static const opt_desc model_options[] = { |
1622 |
|
{STR_MODELID_5_LAB, GTK_SIGNAL_FUNC(mn_modelid_5)}, |
1623 |
|
{STR_MODELID_14_LAB, GTK_SIGNAL_FUNC(mn_modelid_14)}, |
1629 |
|
case 14: active = 1; break; |
1630 |
|
} |
1631 |
|
table_make_option_menu(table, 2, STR_MODELID_CTRL, model_options, active); |
1632 |
+ |
#endif |
1633 |
|
|
1634 |
|
#if EMULATED_68K |
1635 |
|
static const opt_desc cpu_options[] = { |
1653 |
|
|
1654 |
|
w_rom_file = table_make_file_entry(table, 4, STR_ROM_FILE_CTRL, "rom"); |
1655 |
|
|
1656 |
+ |
make_checkbox(box, STR_IDLEWAIT_CTRL, "idlewait", GTK_SIGNAL_FUNC(tb_idlewait)); |
1657 |
+ |
|
1658 |
|
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION |
1659 |
|
make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv)); |
1660 |
|
#endif |
1685 |
|
uint8 XPRAM[XPRAM_SIZE]; |
1686 |
|
void MountVolume(void *fh) { } |
1687 |
|
void FileDiskLayout(loff_t size, uint8 *data, loff_t &start_byte, loff_t &real_size) { } |
1688 |
< |
void WarningAlert(const char *text) { } |
1688 |
> |
void recycle_write_packet(LPPACKET) { } |
1689 |
> |
VOID CALLBACK packet_read_completion(DWORD, DWORD, LPOVERLAPPED) { } |
1690 |
|
|
1691 |
|
|
1692 |
|
/* |
1709 |
|
MessageBox(NULL, text, GetString(title_id), MB_OK | flags); |
1710 |
|
} |
1711 |
|
|
1712 |
< |
static void ErrorAlert(const char *text) |
1712 |
> |
void ErrorAlert(const char *text) |
1713 |
|
{ |
1714 |
|
display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP); |
1715 |
|
} |
1716 |
|
|
1717 |
+ |
void WarningAlert(const char *text) |
1718 |
+ |
{ |
1719 |
+ |
display_alert(STR_WARNING_ALERT_TITLE, text, MB_ICONSTOP); |
1720 |
+ |
} |
1721 |
+ |
|
1722 |
|
|
1723 |
|
/* |
1724 |
|
* Start standalone GUI |
1733 |
|
// Read preferences |
1734 |
|
PrefsInit(argc, argv); |
1735 |
|
|
1736 |
+ |
// Migrate preferences |
1737 |
+ |
PrefsMigrate(); |
1738 |
+ |
|
1739 |
|
// Show preferences editor |
1740 |
|
bool start = PrefsEditor(); |
1741 |
|
|
1742 |
|
// Exit preferences |
1743 |
|
PrefsExit(); |
1744 |
|
|
1745 |
< |
// Transfer control to the Basilisk II executable |
1745 |
> |
// Transfer control to the executable |
1746 |
|
if (start) { |
1747 |
|
char path[_MAX_PATH]; |
1748 |
|
bool ok = GetModuleFileName(NULL, path, sizeof(path)) != 0; |
1752 |
|
*++p = '\0'; |
1753 |
|
SetCurrentDirectory(path); |
1754 |
|
strcpy(b2_path, path); |
1755 |
< |
strcat(b2_path, "BasiliskII.exe"); |
1755 |
> |
strcat(b2_path, PROGRAM_NAME); |
1756 |
> |
strcat(b2_path, ".exe"); |
1757 |
|
HINSTANCE h = ShellExecute(GetDesktopWindow(), "open", |
1758 |
|
b2_path, "", path, SW_SHOWNORMAL); |
1759 |
|
if ((int)h <= 32) |
1760 |
|
ok = false; |
1761 |
|
} |
1762 |
|
if (!ok) { |
1763 |
< |
ErrorAlert("Coult not start BasiliskII executable"); |
1763 |
> |
ErrorAlert("Coult not start " PROGRAM_NAME " executable"); |
1764 |
|
return 1; |
1765 |
|
} |
1766 |
|
} |