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" |
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; |
186 |
|
return table; |
187 |
|
} |
188 |
|
|
189 |
+ |
static GtkWidget *table_make_option_menu(GtkWidget *table, int row, int label_id, const opt_desc *options, int active) |
190 |
+ |
{ |
191 |
+ |
GtkWidget *label, *opt, *menu; |
192 |
+ |
|
193 |
+ |
label = gtk_label_new(GetString(label_id)); |
194 |
+ |
gtk_widget_show(label); |
195 |
+ |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
196 |
+ |
|
197 |
+ |
opt = gtk_option_menu_new(); |
198 |
+ |
gtk_widget_show(opt); |
199 |
+ |
menu = gtk_menu_new(); |
200 |
+ |
|
201 |
+ |
while (options->label_id) { |
202 |
+ |
add_menu_item(menu, options->label_id, options->func); |
203 |
+ |
options++; |
204 |
+ |
} |
205 |
+ |
gtk_menu_set_active(GTK_MENU(menu), active); |
206 |
+ |
|
207 |
+ |
gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu); |
208 |
+ |
gtk_table_attach(GTK_TABLE(table), opt, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
209 |
+ |
return menu; |
210 |
+ |
} |
211 |
+ |
|
212 |
+ |
static GtkWidget *table_make_combobox(GtkWidget *table, int row, int label_id, const char *default_value, GList *glist) |
213 |
+ |
{ |
214 |
+ |
GtkWidget *label, *combo; |
215 |
+ |
char str[32]; |
216 |
+ |
|
217 |
+ |
label = gtk_label_new(GetString(label_id)); |
218 |
+ |
gtk_widget_show(label); |
219 |
+ |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
220 |
+ |
|
221 |
+ |
combo = gtk_combo_new(); |
222 |
+ |
gtk_widget_show(combo); |
223 |
+ |
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); |
224 |
+ |
|
225 |
+ |
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), default_value); |
226 |
+ |
gtk_table_attach(GTK_TABLE(table), combo, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
227 |
+ |
|
228 |
+ |
return combo; |
229 |
+ |
} |
230 |
+ |
|
231 |
+ |
static GtkWidget *table_make_combobox(GtkWidget *table, int row, int label_id, const char *default_value, const combo_desc *options) |
232 |
+ |
{ |
233 |
+ |
GList *glist = NULL; |
234 |
+ |
while (options->label_id) { |
235 |
+ |
glist = g_list_append(glist, (void *)GetString(options->label_id)); |
236 |
+ |
options++; |
237 |
+ |
} |
238 |
+ |
|
239 |
+ |
return table_make_combobox(table, row, label_id, default_value, glist); |
240 |
+ |
} |
241 |
+ |
|
242 |
+ |
static GtkWidget *table_make_file_entry(GtkWidget *table, int row, int label_id, const char *prefs_item, bool only_dirs = false) |
243 |
+ |
{ |
244 |
+ |
GtkWidget *box, *label, *entry, *button; |
245 |
+ |
|
246 |
+ |
label = gtk_label_new(GetString(label_id)); |
247 |
+ |
gtk_widget_show(label); |
248 |
+ |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
249 |
+ |
|
250 |
+ |
const char *str = PrefsFindString(prefs_item); |
251 |
+ |
if (str == NULL) |
252 |
+ |
str = ""; |
253 |
+ |
|
254 |
+ |
box = gtk_hbox_new(FALSE, 4); |
255 |
+ |
gtk_widget_show(box); |
256 |
+ |
gtk_table_attach(GTK_TABLE(table), box, 1, 2, row, row + 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
257 |
+ |
|
258 |
+ |
entry = gtk_entry_new(); |
259 |
+ |
gtk_entry_set_text(GTK_ENTRY(entry), str); |
260 |
+ |
gtk_widget_show(entry); |
261 |
+ |
gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0); |
262 |
+ |
|
263 |
+ |
button = make_browse_button(entry); |
264 |
+ |
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); |
265 |
+ |
g_object_set_data(G_OBJECT(entry), "chooser_button", button); |
266 |
+ |
return entry; |
267 |
+ |
} |
268 |
+ |
|
269 |
|
static GtkWidget *make_option_menu(GtkWidget *top, int label_id, const opt_desc *options, int active) |
270 |
|
{ |
271 |
|
GtkWidget *box, *label, *opt, *menu; |
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; |
228 |
– |
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); |
237 |
– |
|
238 |
– |
GList *glist = NULL; |
239 |
– |
while (options->label_id) { |
240 |
– |
glist = g_list_append(glist, (void *)GetString(options->label_id)); |
241 |
– |
options++; |
242 |
– |
} |
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)); |
249 |
< |
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" |
457 |
|
// Menu item descriptions |
458 |
|
static GtkItemFactoryEntry menu_items[] = { |
459 |
|
{(gchar *)GetString(STR_PREFS_MENU_FILE_GTK), NULL, NULL, 0, "<Branch>"}, |
460 |
< |
{(gchar *)GetString(STR_PREFS_ITEM_START_GTK), NULL, GTK_SIGNAL_FUNC(cb_start), 0, NULL}, |
460 |
> |
{(gchar *)GetString(STR_PREFS_ITEM_START_GTK), "<control>S", GTK_SIGNAL_FUNC(cb_start), 0, NULL}, |
461 |
|
{(gchar *)GetString(STR_PREFS_ITEM_ZAP_PRAM_GTK), NULL, GTK_SIGNAL_FUNC(cb_zap_pram), 0, NULL}, |
462 |
|
{(gchar *)GetString(STR_PREFS_ITEM_SEPL_GTK), NULL, NULL, 0, "<Separator>"}, |
463 |
|
{(gchar *)GetString(STR_PREFS_ITEM_QUIT_GTK), "<control>Q", GTK_SIGNAL_FUNC(cb_quit), 0, NULL}, |
464 |
|
{(gchar *)GetString(STR_HELP_MENU_GTK), NULL, NULL, 0, "<LastBranch>"}, |
465 |
< |
{(gchar *)GetString(STR_HELP_ITEM_ABOUT_GTK), NULL, GTK_SIGNAL_FUNC(cb_about), 0, NULL} |
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 |
+ |
#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); |
523 |
|
|
524 |
|
static const opt_desc buttons[] = { |
525 |
|
{STR_START_BUTTON, GTK_SIGNAL_FUNC(cb_start)}, |
394 |
– |
{STR_PREFS_ITEM_ZAP_PRAM, GTK_SIGNAL_FUNC(cb_zap_pram)}, |
395 |
– |
{STR_ABOUT_BUTTON, GTK_SIGNAL_FUNC(cb_about)}, |
526 |
|
{STR_QUIT_BUTTON, GTK_SIGNAL_FUNC(cb_quit)}, |
527 |
|
{0, NULL} |
528 |
|
}; |
539 |
|
* "Volumes" pane |
540 |
|
*/ |
541 |
|
|
542 |
+ |
static GtkWidget *w_enableextfs, *w_extdrives, *w_cdrom_drive; |
543 |
|
static GtkWidget *volume_list; |
544 |
|
static int selected_volume; |
545 |
|
|
546 |
+ |
// Set sensitivity of widgets |
547 |
+ |
static void set_volumes_sensitive(void) |
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 |
556 |
|
static void cl_selected(GtkWidget *list, int row, int column) |
557 |
|
{ |
573 |
|
gchar *file = (gchar *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(assoc->req)); |
574 |
|
|
575 |
|
const gchar *str = gtk_entry_get_text(GTK_ENTRY(assoc->entry)); |
576 |
< |
int size = atoi(str); |
576 |
> |
size_t size = atoi(str) << 20; |
577 |
|
|
578 |
< |
char cmd[1024]; |
579 |
< |
sprintf(cmd, "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", file, size); |
580 |
< |
int ret = system(cmd); |
441 |
< |
if (ret == 0) |
578 |
> |
int fd = _open(file, _O_WRONLY | _O_CREAT | _O_BINARY | _O_TRUNC, _S_IREAD | _S_IWRITE); |
579 |
> |
if (fd >= 0) { |
580 |
> |
if (_chsize(fd, size) == 0) |
581 |
|
gtk_clist_append(GTK_CLIST(volume_list), &file); |
582 |
+ |
_close(fd); |
583 |
+ |
} |
584 |
|
gtk_widget_destroy(GTK_WIDGET(assoc->req)); |
585 |
|
delete assoc; |
586 |
|
} |
629 |
|
static void mn_boot_any(...) {PrefsReplaceInt32("bootdriver", 0);} |
630 |
|
static void mn_boot_cdrom(...) {PrefsReplaceInt32("bootdriver", CDROMRefNum);} |
631 |
|
|
632 |
+ |
// "Enable external file system" button toggled |
633 |
+ |
static void tb_enableextfs(GtkWidget *widget) |
634 |
+ |
{ |
635 |
+ |
PrefsReplaceBool("enableextfs", GTK_TOGGLE_BUTTON(widget)->active); |
636 |
+ |
set_volumes_sensitive(); |
637 |
+ |
} |
638 |
+ |
|
639 |
|
// "No CD-ROM Driver" button toggled |
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 |
662 |
+ |
static void tb_pollmedia(GtkWidget *widget) |
663 |
+ |
{ |
664 |
+ |
PrefsReplaceBool("pollmedia", GTK_TOGGLE_BUTTON(widget)->active); |
665 |
|
} |
666 |
|
|
667 |
|
// Read settings from widgets and set preferences |
675 |
|
gtk_clist_get_text(GTK_CLIST(volume_list), i, 0, &str); |
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 |
|
|
688 |
|
// Create "Volumes" pane |
731 |
|
menu = make_option_menu(box, STR_BOOTDRIVER_CTRL, options, active); |
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); |
744 |
+ |
w_enableextfs = make_checkbox(box, STR_EXTFS_ENABLE_CTRL, "enableextfs", GTK_SIGNAL_FUNC(tb_enableextfs)); |
745 |
+ |
w_extdrives = make_file_entry(box, STR_EXTFS_DRIVES_CTRL, "extdrives", true); |
746 |
+ |
|
747 |
+ |
set_volumes_sensitive(); |
748 |
|
} |
749 |
|
|
750 |
|
|
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 |
|
|
1149 |
|
// Set sensitivity of widgets |
1150 |
|
static void set_input_sensitive(void) |
1151 |
|
{ |
1152 |
< |
gtk_widget_set_sensitive(w_keycode_file, PrefsFindBool("keycodes")); |
1152 |
> |
const bool use_keycodes = PrefsFindBool("keycodes"); |
1153 |
> |
gtk_widget_set_sensitive(w_keycode_file, use_keycodes); |
1154 |
> |
gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_keycode_file), "chooser_button")), use_keycodes); |
1155 |
|
gtk_widget_set_sensitive(w_mouse_wheel_lines, PrefsFindInt32("mousewheelmode") == 1); |
1156 |
|
} |
1157 |
|
|
1181 |
|
// Create "Input" pane |
1182 |
|
static void create_input_pane(GtkWidget *top) |
1183 |
|
{ |
1184 |
< |
GtkWidget *box, *hbox, *menu, *label; |
1184 |
> |
GtkWidget *box, *hbox, *menu, *label, *button; |
1185 |
|
GtkObject *adj; |
1186 |
|
|
1187 |
|
box = make_pane(top, STR_INPUT_PANE_TITLE); |
1188 |
|
|
1189 |
|
make_checkbox(box, STR_KEYCODES_CTRL, "keycodes", GTK_SIGNAL_FUNC(tb_keycodes)); |
1190 |
< |
w_keycode_file = make_file_entry(box, STR_KEYCODE_FILE_CTRL, "keycodefile"); |
1190 |
> |
|
1191 |
> |
hbox = gtk_hbox_new(FALSE, 4); |
1192 |
> |
gtk_widget_show(hbox); |
1193 |
> |
gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); |
1194 |
> |
|
1195 |
> |
label = gtk_label_new(GetString(STR_KEYCODES_CTRL)); |
1196 |
> |
gtk_widget_show(label); |
1197 |
> |
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1198 |
> |
|
1199 |
> |
const char *str = PrefsFindString("keycodefile"); |
1200 |
> |
if (str == NULL) |
1201 |
> |
str = ""; |
1202 |
> |
|
1203 |
> |
w_keycode_file = gtk_entry_new(); |
1204 |
> |
gtk_entry_set_text(GTK_ENTRY(w_keycode_file), str); |
1205 |
> |
gtk_widget_show(w_keycode_file); |
1206 |
> |
gtk_box_pack_start(GTK_BOX(hbox), w_keycode_file, TRUE, TRUE, 0); |
1207 |
> |
|
1208 |
> |
button = make_browse_button(w_keycode_file); |
1209 |
> |
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
1210 |
> |
g_object_set_data(G_OBJECT(w_keycode_file), "chooser_button", button); |
1211 |
|
|
1212 |
|
make_separator(box); |
1213 |
|
|
1244 |
|
* "Serial" pane |
1245 |
|
*/ |
1246 |
|
|
1247 |
< |
static GtkWidget *w_seriala, *w_portfile0, *w_portfile0_browse; |
1248 |
< |
static GtkWidget *w_serialb, *w_portfile1, *w_portfile1_browse; |
1247 |
> |
static GtkWidget *w_seriala, *w_portfile0; |
1248 |
> |
static GtkWidget *w_serialb, *w_portfile1; |
1249 |
|
|
1250 |
|
// Set sensitivity of widgets |
1251 |
|
static void set_serial_sensitive(void) |
1256 |
|
str = gtk_entry_get_text(GTK_ENTRY(w_seriala)); |
1257 |
|
is_file = strcmp(str, "FILE") == 0; |
1258 |
|
gtk_widget_set_sensitive(w_portfile0, is_file); |
1259 |
< |
gtk_widget_set_sensitive(w_portfile0_browse, is_file); |
1259 |
> |
gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_portfile0), "chooser_button")), is_file); |
1260 |
|
|
1261 |
|
str = gtk_entry_get_text(GTK_ENTRY(w_serialb)); |
1262 |
|
is_file = strcmp(str, "FILE") == 0; |
1263 |
|
gtk_widget_set_sensitive(w_portfile1, is_file); |
1264 |
< |
gtk_widget_set_sensitive(w_portfile1_browse, is_file); |
1264 |
> |
gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data(G_OBJECT(w_portfile1), "chooser_button")), is_file); |
1265 |
|
} |
1266 |
|
|
1267 |
|
// Read settings from widgets and set preferences |
1285 |
|
// Port changed in combo |
1286 |
|
static void cb_serial_port_changed(...) |
1287 |
|
{ |
1025 |
– |
printf("serial port changed\n"); |
1288 |
|
set_serial_sensitive(); |
1289 |
|
} |
1290 |
|
|
1315 |
|
box = make_pane(top, STR_SERIAL_PANE_TITLE); |
1316 |
|
table = make_table(box, 2, 5); |
1317 |
|
|
1056 |
– |
label = gtk_label_new(GetString(STR_SERIALA_CTRL)); |
1057 |
– |
gtk_widget_show(label); |
1058 |
– |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1059 |
– |
|
1318 |
|
GList *glist = add_serial_names(); |
1061 |
– |
combo = gtk_combo_new(); |
1062 |
– |
gtk_widget_show(combo); |
1063 |
– |
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); |
1319 |
|
const char *str = PrefsFindString("seriala"); |
1320 |
< |
if (str == NULL) |
1066 |
< |
str = ""; |
1067 |
< |
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); |
1068 |
< |
gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1320 |
> |
combo = table_make_combobox(table, 0, STR_SERIALA_CTRL, str, glist); |
1321 |
|
w_seriala = GTK_COMBO(combo)->entry; |
1322 |
|
gtk_signal_connect(GTK_OBJECT(w_seriala), "changed", GTK_SIGNAL_FUNC(cb_serial_port_changed), NULL); |
1323 |
|
|
1324 |
< |
label = gtk_label_new(GetString(STR_FILE_CTRL)); |
1073 |
< |
gtk_widget_show(label); |
1074 |
< |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1075 |
< |
|
1076 |
< |
hbox = gtk_hbox_new(FALSE, 4); |
1077 |
< |
gtk_widget_show(hbox); |
1078 |
< |
gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1079 |
< |
|
1080 |
< |
w_portfile0 = gtk_entry_new(); |
1081 |
< |
str = PrefsFindString("portfile0"); |
1082 |
< |
if (str == NULL) |
1083 |
< |
str = "C:\\B2TEMP0.OUT"; |
1084 |
< |
gtk_entry_set_text(GTK_ENTRY(w_portfile0), str); |
1085 |
< |
gtk_widget_show(w_portfile0); |
1086 |
< |
gtk_box_pack_start(GTK_BOX(hbox), w_portfile0, TRUE, TRUE, 0); |
1087 |
< |
|
1088 |
< |
w_portfile0_browse = make_browse_button(w_portfile0); |
1089 |
< |
gtk_box_pack_start(GTK_BOX(hbox), w_portfile0_browse, FALSE, FALSE, 0); |
1324 |
> |
w_portfile0 = table_make_file_entry(table, 1, STR_FILE_CTRL, "portfile0"); |
1325 |
|
|
1326 |
|
sep = gtk_hseparator_new(); |
1327 |
|
gtk_widget_show(sep); |
1328 |
|
gtk_table_attach(GTK_TABLE(table), sep, 0, 2, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1329 |
|
|
1095 |
– |
label = gtk_label_new(GetString(STR_SERIALB_CTRL)); |
1096 |
– |
gtk_widget_show(label); |
1097 |
– |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1098 |
– |
|
1099 |
– |
combo = gtk_combo_new(); |
1100 |
– |
gtk_widget_show(combo); |
1101 |
– |
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); |
1330 |
|
str = PrefsFindString("serialb"); |
1331 |
< |
if (str == NULL) |
1104 |
< |
str = ""; |
1105 |
< |
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); |
1106 |
< |
gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1331 |
> |
combo = table_make_combobox(table, 3, STR_SERIALB_CTRL, str, glist); |
1332 |
|
w_serialb = GTK_COMBO(combo)->entry; |
1333 |
|
gtk_signal_connect(GTK_OBJECT(w_serialb), "changed", GTK_SIGNAL_FUNC(cb_serial_port_changed), NULL); |
1334 |
|
|
1335 |
< |
label = gtk_label_new(GetString(STR_FILE_CTRL)); |
1111 |
< |
gtk_widget_show(label); |
1112 |
< |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1113 |
< |
|
1114 |
< |
hbox = gtk_hbox_new(FALSE, 4); |
1115 |
< |
gtk_widget_show(hbox); |
1116 |
< |
gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 4, 5, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1117 |
< |
|
1118 |
< |
w_portfile1 = gtk_entry_new(); |
1119 |
< |
str = PrefsFindString("portfile1"); |
1120 |
< |
if (str == NULL) |
1121 |
< |
str = "C:\\B2TEMP1.OUT"; |
1122 |
< |
gtk_entry_set_text(GTK_ENTRY(w_portfile1), str); |
1123 |
< |
gtk_widget_show(w_portfile1); |
1124 |
< |
gtk_box_pack_start(GTK_BOX(hbox), w_portfile1, TRUE, TRUE, 0); |
1125 |
< |
|
1126 |
< |
w_portfile1_browse = make_browse_button(w_portfile1); |
1127 |
< |
gtk_box_pack_start(GTK_BOX(hbox), w_portfile1_browse, FALSE, FALSE, 0); |
1335 |
> |
w_portfile1 = table_make_file_entry(table, 4, STR_FILE_CTRL, "portfile1"); |
1336 |
|
|
1337 |
|
set_serial_sensitive(); |
1338 |
|
} |
1342 |
|
* "Ethernet" pane |
1343 |
|
*/ |
1344 |
|
|
1345 |
< |
static GtkWidget *w_ether, *w_udp_port; |
1345 |
> |
static GtkWidget *w_ftp_port_list, *w_tcp_port_list; |
1346 |
|
|
1347 |
|
// Set sensitivity of widgets |
1348 |
|
static void set_ethernet_sensitive(void) |
1349 |
|
{ |
1350 |
+ |
const char *str = PrefsFindString("ether"); |
1351 |
+ |
|
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)); |
1361 |
< |
if (str && strlen(str)) |
1362 |
< |
PrefsReplaceString("ether", str); |
1363 |
< |
else |
1364 |
< |
PrefsRemoveItem("ether"); |
1360 |
> |
const char *str = PrefsFindString("ether"); |
1361 |
> |
|
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)); |
1367 |
> |
PrefsReplaceString("tcp_port", str); |
1368 |
> |
} |
1369 |
|
} |
1370 |
|
|
1371 |
< |
// Add names of ethernet interfaces |
1372 |
< |
static GList *add_ether_names(void) |
1371 |
> |
// Ethernet emulation type changed in menulist |
1372 |
> |
static void cb_ether_changed(...) |
1373 |
|
{ |
1374 |
< |
GList *glist = NULL; |
1374 |
> |
set_ethernet_sensitive(); |
1375 |
> |
} |
1376 |
|
|
1377 |
< |
// TODO: Get list of all Ethernet interfaces |
1378 |
< |
#ifdef HAVE_SLIRP |
1379 |
< |
static char s_slirp[] = "slirp"; |
1380 |
< |
glist = g_list_append(glist, s_slirp); |
1381 |
< |
#endif |
1164 |
< |
#if 0 |
1165 |
< |
if (glist) |
1166 |
< |
g_list_sort(glist, gl_str_cmp); |
1167 |
< |
else |
1168 |
< |
#endif |
1169 |
< |
glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB)); |
1170 |
< |
return glist; |
1377 |
> |
// Ethernet option "None" selected |
1378 |
> |
static void mn_ether_none(void) |
1379 |
> |
{ |
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 |
+ |
// Create ethernet interfaces menu |
1406 |
+ |
static int create_ether_menu(GtkWidget *menu) |
1407 |
+ |
{ |
1408 |
+ |
int active = -1; |
1409 |
+ |
int n_items = 0; |
1410 |
+ |
const char *ether = PrefsFindString("ether"); |
1411 |
+ |
const char *etherguid = PrefsFindString("etherguid"); |
1412 |
+ |
|
1413 |
+ |
add_menu_item(menu, STR_NONE_LAB, (GtkSignalFunc)mn_ether_none); |
1414 |
+ |
if (ether == NULL) |
1415 |
+ |
active = n_items; |
1416 |
+ |
n_items++; |
1417 |
+ |
|
1418 |
+ |
add_menu_item(menu, "Basilisk II Router", (GtkSignalFunc)mn_ether_router); |
1419 |
+ |
if (ether && strcmp(ether, "router") == 0) |
1420 |
+ |
active = n_items; |
1421 |
+ |
n_items++; |
1422 |
+ |
|
1423 |
+ |
add_menu_item(menu, "Basilisk II Slirp", (GtkSignalFunc)mn_ether_router); |
1424 |
+ |
if (ether && strcmp(ether, "slirp") == 0) |
1425 |
+ |
active = n_items; |
1426 |
+ |
n_items++; |
1427 |
+ |
|
1428 |
+ |
PacketOpenAdapter("", 0); |
1429 |
+ |
{ |
1430 |
+ |
ULONG sz; |
1431 |
+ |
char names[1024]; |
1432 |
+ |
sz = sizeof(names); |
1433 |
+ |
if (PacketGetAdapterNames(NULL, names, &sz) == ERROR_SUCCESS) { |
1434 |
+ |
char *p = names; |
1435 |
+ |
while (*p) { |
1436 |
+ |
const char DEVICE_HEADER[] = "\\Device\\B2ether_"; |
1437 |
+ |
if (strnicmp(p, DEVICE_HEADER, sizeof(DEVICE_HEADER) - 1) == 0) { |
1438 |
+ |
LPADAPTER fd = PacketOpenAdapter(p + sizeof(DEVICE_HEADER) - 1, 0); |
1439 |
+ |
if (fd) { |
1440 |
+ |
char guid[256]; |
1441 |
+ |
sprintf(guid, "%s", p + sizeof(DEVICE_HEADER) - 1); |
1442 |
+ |
const char *name = ether_guid_to_name(guid); |
1443 |
+ |
if (name && (name = g_locale_to_utf8(name, -1, NULL, NULL, NULL))) { |
1444 |
+ |
add_menu_item(menu, name, (GtkSignalFunc)mn_ether_b2ether, strdup(guid)); |
1445 |
+ |
if (etherguid && strcmp(guid, etherguid) == 0 && |
1446 |
+ |
ether && strcmp(ether, "b2ether") == 0) |
1447 |
+ |
active = n_items; |
1448 |
+ |
n_items++; |
1449 |
+ |
} |
1450 |
+ |
PacketCloseAdapter(fd); |
1451 |
+ |
} |
1452 |
+ |
} |
1453 |
+ |
p += strlen(p) + 1; |
1454 |
+ |
} |
1455 |
+ |
} |
1456 |
+ |
} |
1457 |
+ |
PacketCloseAdapter(NULL); |
1458 |
+ |
|
1459 |
+ |
return active; |
1460 |
+ |
} |
1461 |
|
|
1462 |
|
// Create "Ethernet" pane |
1463 |
|
static void create_ethernet_pane(GtkWidget *top) |
1464 |
|
{ |
1465 |
< |
GtkWidget *box, *hbox, *table, *label, *combo, *sep, *entry; |
1465 |
> |
GtkWidget *box, *hbox, *table, *label, *sep, *entry, *opt, *menu, *item; |
1466 |
|
|
1467 |
|
box = make_pane(top, STR_NETWORK_PANE_TITLE); |
1468 |
|
table = make_table(box, 2, 5); |
1471 |
|
gtk_widget_show(label); |
1472 |
|
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1473 |
|
|
1474 |
< |
GList *glist = add_ether_names(); |
1475 |
< |
combo = gtk_combo_new(); |
1476 |
< |
gtk_widget_show(combo); |
1477 |
< |
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); |
1478 |
< |
const char *str = PrefsFindString("ether"); |
1474 |
> |
opt = gtk_option_menu_new(); |
1475 |
> |
gtk_widget_show(opt); |
1476 |
> |
menu = gtk_menu_new(); |
1477 |
> |
int active = create_ether_menu(menu); |
1478 |
> |
if (active >= 0) |
1479 |
> |
gtk_menu_set_active(GTK_MENU(menu), active); |
1480 |
> |
gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu); |
1481 |
> |
gtk_table_attach(GTK_TABLE(table), opt, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1482 |
> |
gtk_signal_connect(GTK_OBJECT(opt), "changed", GTK_SIGNAL_FUNC(cb_ether_changed), NULL); |
1483 |
> |
|
1484 |
> |
sep = gtk_hseparator_new(); |
1485 |
> |
gtk_widget_show(sep); |
1486 |
> |
gtk_table_attach(GTK_TABLE(table), sep, 0, 2, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1487 |
> |
|
1488 |
> |
label = gtk_label_new(GetString(STR_ETHER_FTP_PORT_LIST_CTRL)); |
1489 |
> |
gtk_widget_show(label); |
1490 |
> |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1491 |
> |
|
1492 |
> |
entry = gtk_entry_new(); |
1493 |
> |
const char *str = PrefsFindString("ftp_port_list"); |
1494 |
|
if (str == NULL) |
1495 |
|
str = ""; |
1496 |
< |
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); |
1497 |
< |
gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1498 |
< |
w_ether = GTK_COMBO(combo)->entry; |
1496 |
> |
gtk_entry_set_text(GTK_ENTRY(entry), str); |
1497 |
> |
gtk_widget_show(entry); |
1498 |
> |
gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 2, 3, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1499 |
> |
w_ftp_port_list = entry; |
1500 |
> |
|
1501 |
> |
label = gtk_label_new(GetString(STR_ETHER_TCP_PORT_LIST_CTRL)); |
1502 |
> |
gtk_widget_show(label); |
1503 |
> |
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1504 |
> |
|
1505 |
> |
entry = gtk_entry_new(); |
1506 |
> |
str = PrefsFindString("tcp_port"); |
1507 |
> |
if (str == NULL) |
1508 |
> |
str = ""; |
1509 |
> |
gtk_entry_set_text(GTK_ENTRY(entry), str); |
1510 |
> |
gtk_widget_show(entry); |
1511 |
> |
gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 3, 4, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1512 |
> |
w_tcp_port_list = entry; |
1513 |
|
|
1514 |
|
set_ethernet_sensitive(); |
1515 |
|
} |
1519 |
|
* "Memory/Misc" pane |
1520 |
|
*/ |
1521 |
|
|
1522 |
< |
static GtkObject *w_ramsize_adj; |
1522 |
> |
static GtkWidget *w_ramsize; |
1523 |
|
static GtkWidget *w_rom_file; |
1524 |
|
|
1525 |
+ |
// Don't use CPU when idle? |
1526 |
+ |
static void tb_idlewait(GtkWidget *widget) |
1527 |
+ |
{ |
1528 |
+ |
PrefsReplaceBool("idlewait", GTK_TOGGLE_BUTTON(widget)->active); |
1529 |
+ |
} |
1530 |
+ |
|
1531 |
|
// "Ignore SEGV" button toggled |
1532 |
|
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION |
1533 |
|
static void tb_ignoresegv(GtkWidget *widget) |
1550 |
|
// Read settings from widgets and set preferences |
1551 |
|
static void read_memory_settings(void) |
1552 |
|
{ |
1553 |
< |
PrefsReplaceInt32("ramsize", int(GTK_ADJUSTMENT(w_ramsize_adj)->value) << 20); |
1553 |
> |
const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_ramsize)->entry)); |
1554 |
> |
PrefsReplaceInt32("ramsize", atoi(str) << 20); |
1555 |
|
|
1556 |
< |
const char *str = get_file_entry_path(w_rom_file); |
1556 |
> |
str = get_file_entry_path(w_rom_file); |
1557 |
|
if (str && strlen(str)) |
1558 |
|
PrefsReplaceString("rom", str); |
1559 |
|
else |
1564 |
|
// Create "Memory/Misc" pane |
1565 |
|
static void create_memory_pane(GtkWidget *top) |
1566 |
|
{ |
1567 |
< |
GtkWidget *box, *hbox, *vbox, *hbox2, *label, *scale; |
1567 |
> |
GtkWidget *box, *hbox, *table, *label, *scale, *menu; |
1568 |
|
|
1569 |
|
box = make_pane(top, STR_MEMORY_MISC_PANE_TITLE); |
1570 |
+ |
table = make_table(box, 2, 5); |
1571 |
|
|
1572 |
< |
hbox = gtk_hbox_new(FALSE, 4); |
1573 |
< |
gtk_widget_show(hbox); |
1574 |
< |
|
1575 |
< |
label = gtk_label_new(GetString(STR_RAMSIZE_SLIDER)); |
1576 |
< |
gtk_widget_show(label); |
1577 |
< |
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1578 |
< |
|
1579 |
< |
vbox = gtk_vbox_new(FALSE, 4); |
1580 |
< |
gtk_widget_show(vbox); |
1581 |
< |
|
1582 |
< |
gfloat min, max; |
1583 |
< |
min = 1; |
1584 |
< |
max = 1024; |
1585 |
< |
w_ramsize_adj = gtk_adjustment_new(min, min, max, 1, 16, 0); |
1586 |
< |
gtk_adjustment_set_value(GTK_ADJUSTMENT(w_ramsize_adj), PrefsFindInt32("ramsize") >> 20); |
1587 |
< |
|
1588 |
< |
scale = gtk_hscale_new(GTK_ADJUSTMENT(w_ramsize_adj)); |
1589 |
< |
gtk_widget_show(scale); |
1590 |
< |
gtk_scale_set_digits(GTK_SCALE(scale), 0); |
1591 |
< |
gtk_box_pack_start(GTK_BOX(vbox), scale, TRUE, TRUE, 0); |
1267 |
< |
|
1268 |
< |
hbox2 = gtk_hbox_new(FALSE, 4); |
1269 |
< |
gtk_widget_show(hbox2); |
1270 |
< |
|
1271 |
< |
char val[32]; |
1272 |
< |
sprintf(val, GetString(STR_RAMSIZE_FMT), int(min)); |
1273 |
< |
label = gtk_label_new(val); |
1274 |
< |
gtk_widget_show(label); |
1275 |
< |
gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); |
1276 |
< |
|
1277 |
< |
sprintf(val, GetString(STR_RAMSIZE_FMT), int(max)); |
1278 |
< |
label = gtk_label_new(val); |
1279 |
< |
gtk_widget_show(label); |
1280 |
< |
gtk_box_pack_end(GTK_BOX(hbox2), label, FALSE, FALSE, 0); |
1281 |
< |
gtk_box_pack_start(GTK_BOX(vbox), hbox2, TRUE, TRUE, 0); |
1282 |
< |
gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); |
1283 |
< |
gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0); |
1572 |
> |
static const combo_desc options[] = { |
1573 |
> |
#ifndef SHEEPSHAVER |
1574 |
> |
STR_RAMSIZE_2MB_LAB, |
1575 |
> |
#endif |
1576 |
> |
STR_RAMSIZE_4MB_LAB, |
1577 |
> |
STR_RAMSIZE_8MB_LAB, |
1578 |
> |
STR_RAMSIZE_16MB_LAB, |
1579 |
> |
STR_RAMSIZE_32MB_LAB, |
1580 |
> |
STR_RAMSIZE_64MB_LAB, |
1581 |
> |
STR_RAMSIZE_128MB_LAB, |
1582 |
> |
STR_RAMSIZE_256MB_LAB, |
1583 |
> |
STR_RAMSIZE_512MB_LAB, |
1584 |
> |
#ifndef SHEEPSHAVER |
1585 |
> |
STR_RAMSIZE_1024MB_LAB, |
1586 |
> |
#endif |
1587 |
> |
0 |
1588 |
> |
}; |
1589 |
> |
char default_ramsize[10]; |
1590 |
> |
sprintf(default_ramsize, "%d", PrefsFindInt32("ramsize") >> 20); |
1591 |
> |
w_ramsize = table_make_combobox(table, 0, STR_RAMSIZE_CTRL, default_ramsize, options); |
1592 |
|
|
1593 |
+ |
#ifndef SHEEPSHAVER |
1594 |
|
static const opt_desc model_options[] = { |
1595 |
|
{STR_MODELID_5_LAB, GTK_SIGNAL_FUNC(mn_modelid_5)}, |
1596 |
|
{STR_MODELID_14_LAB, GTK_SIGNAL_FUNC(mn_modelid_14)}, |
1601 |
|
case 5: active = 0; break; |
1602 |
|
case 14: active = 1; break; |
1603 |
|
} |
1604 |
< |
make_option_menu(box, STR_MODELID_CTRL, model_options, active); |
1604 |
> |
table_make_option_menu(table, 2, STR_MODELID_CTRL, model_options, active); |
1605 |
> |
#endif |
1606 |
|
|
1607 |
|
#if EMULATED_68K |
1608 |
|
static const opt_desc cpu_options[] = { |
1621 |
|
case 3: active = fpu ? 3 : 2; break; |
1622 |
|
case 4: active = 4; |
1623 |
|
} |
1624 |
< |
make_option_menu(box, STR_CPU_CTRL, cpu_options, active); |
1624 |
> |
table_make_option_menu(table, 3, STR_CPU_CTRL, cpu_options, active); |
1625 |
|
#endif |
1626 |
|
|
1627 |
< |
w_rom_file = make_file_entry(box, STR_ROM_FILE_CTRL, "rom"); |
1627 |
> |
w_rom_file = table_make_file_entry(table, 4, STR_ROM_FILE_CTRL, "rom"); |
1628 |
> |
|
1629 |
> |
make_checkbox(box, STR_IDLEWAIT_CTRL, "idlewait", GTK_SIGNAL_FUNC(tb_idlewait)); |
1630 |
|
|
1631 |
|
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION |
1632 |
|
make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv)); |
1658 |
|
uint8 XPRAM[XPRAM_SIZE]; |
1659 |
|
void MountVolume(void *fh) { } |
1660 |
|
void FileDiskLayout(loff_t size, uint8 *data, loff_t &start_byte, loff_t &real_size) { } |
1661 |
< |
void WarningAlert(const char *text) { } |
1661 |
> |
void recycle_write_packet(LPPACKET) { } |
1662 |
> |
VOID CALLBACK packet_read_completion(DWORD, DWORD, LPOVERLAPPED) { } |
1663 |
|
|
1664 |
|
|
1665 |
|
/* |
1674 |
|
|
1675 |
|
|
1676 |
|
/* |
1677 |
+ |
* Display alerts |
1678 |
+ |
*/ |
1679 |
+ |
|
1680 |
+ |
static void display_alert(int title_id, const char *text, int flags) |
1681 |
+ |
{ |
1682 |
+ |
MessageBox(NULL, text, GetString(title_id), MB_OK | flags); |
1683 |
+ |
} |
1684 |
+ |
|
1685 |
+ |
void ErrorAlert(const char *text) |
1686 |
+ |
{ |
1687 |
+ |
display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP); |
1688 |
+ |
} |
1689 |
+ |
|
1690 |
+ |
void WarningAlert(const char *text) |
1691 |
+ |
{ |
1692 |
+ |
display_alert(STR_WARNING_ALERT_TITLE, text, MB_ICONSTOP); |
1693 |
+ |
} |
1694 |
+ |
|
1695 |
+ |
|
1696 |
+ |
/* |
1697 |
|
* Start standalone GUI |
1698 |
|
*/ |
1699 |
|
|
1706 |
|
// Read preferences |
1707 |
|
PrefsInit(argc, argv); |
1708 |
|
|
1709 |
+ |
// Migrate preferences |
1710 |
+ |
PrefsMigrate(); |
1711 |
+ |
|
1712 |
|
// Show preferences editor |
1713 |
|
bool start = PrefsEditor(); |
1714 |
|
|
1715 |
|
// Exit preferences |
1716 |
|
PrefsExit(); |
1717 |
|
|
1718 |
< |
// Transfer control to the Basilisk II executable |
1718 |
> |
// Transfer control to the executable |
1719 |
|
if (start) { |
1720 |
< |
printf("Start Basilisk II\n"); |
1720 |
> |
char path[_MAX_PATH]; |
1721 |
> |
bool ok = GetModuleFileName(NULL, path, sizeof(path)) != 0; |
1722 |
> |
if (ok) { |
1723 |
> |
char b2_path[_MAX_PATH]; |
1724 |
> |
char *p = strrchr(path, '\\'); |
1725 |
> |
*++p = '\0'; |
1726 |
> |
SetCurrentDirectory(path); |
1727 |
> |
strcpy(b2_path, path); |
1728 |
> |
strcat(b2_path, PROGRAM_NAME); |
1729 |
> |
strcat(b2_path, ".exe"); |
1730 |
> |
HINSTANCE h = ShellExecute(GetDesktopWindow(), "open", |
1731 |
> |
b2_path, "", path, SW_SHOWNORMAL); |
1732 |
> |
if ((int)h <= 32) |
1733 |
> |
ok = false; |
1734 |
> |
} |
1735 |
> |
if (!ok) { |
1736 |
> |
ErrorAlert("Coult not start " PROGRAM_NAME " executable"); |
1737 |
> |
return 1; |
1738 |
> |
} |
1739 |
|
} |
1740 |
|
|
1741 |
|
return 0; |