1 |
|
/* |
2 |
|
* prefs_editor_gtk.cpp - Preferences editor, Unix implementation using GTK+ |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2002 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2005 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
52 |
|
static void create_input_pane(GtkWidget *top); |
53 |
|
static void create_serial_pane(GtkWidget *top); |
54 |
|
static void create_memory_pane(GtkWidget *top); |
55 |
+ |
static void create_jit_pane(GtkWidget *top); |
56 |
|
static void read_settings(void); |
57 |
|
|
58 |
|
|
65 |
|
GtkSignalFunc func; |
66 |
|
}; |
67 |
|
|
68 |
+ |
struct combo_desc { |
69 |
+ |
int label_id; |
70 |
+ |
}; |
71 |
+ |
|
72 |
|
static void add_menu_item(GtkWidget *menu, int label_id, GtkSignalFunc func) |
73 |
|
{ |
74 |
|
GtkWidget *item = gtk_menu_item_new_with_label(GetString(label_id)); |
208 |
|
return button; |
209 |
|
} |
210 |
|
|
211 |
+ |
static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *prefs_item, const combo_desc *options) |
212 |
+ |
{ |
213 |
+ |
GtkWidget *box, *label, *combo; |
214 |
+ |
char str[32]; |
215 |
+ |
|
216 |
+ |
box = gtk_hbox_new(FALSE, 4); |
217 |
+ |
gtk_widget_show(box); |
218 |
+ |
gtk_box_pack_start(GTK_BOX(top), box, FALSE, FALSE, 0); |
219 |
+ |
|
220 |
+ |
label = gtk_label_new(GetString(label_id)); |
221 |
+ |
gtk_widget_show(label); |
222 |
+ |
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); |
223 |
+ |
|
224 |
+ |
GList *glist = NULL; |
225 |
+ |
while (options->label_id) { |
226 |
+ |
glist = g_list_append(glist, (void *)GetString(options->label_id)); |
227 |
+ |
options++; |
228 |
+ |
} |
229 |
+ |
|
230 |
+ |
combo = gtk_combo_new(); |
231 |
+ |
gtk_widget_show(combo); |
232 |
+ |
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); |
233 |
+ |
|
234 |
+ |
sprintf(str, "%d", PrefsFindInt32(prefs_item)); |
235 |
+ |
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); |
236 |
+ |
gtk_box_pack_start(GTK_BOX(box), combo, TRUE, TRUE, 0); |
237 |
+ |
|
238 |
+ |
return combo; |
239 |
+ |
} |
240 |
|
|
241 |
+ |
|
242 |
|
/* |
243 |
|
* Show preferences editor |
244 |
|
* Returns true when user clicked on "Start", false otherwise |
306 |
|
dialog = gnome_about_new( |
307 |
|
"Basilisk II", |
308 |
|
version, |
309 |
< |
"Copyright (C) 1997-2002 Christian Bauer", |
309 |
> |
"Copyright (C) 1997-2004 Christian Bauer", |
310 |
|
authors, |
311 |
|
"Basilisk II comes with ABSOLUTELY NO WARRANTY." |
312 |
|
"This is free software, and you are welcome to redistribute it" |
322 |
|
char str[512]; |
323 |
|
sprintf(str, |
324 |
|
"Basilisk II\nVersion %d.%d\n\n" |
325 |
< |
"Copyright (C) 1997-2002 Christian Bauer et al.\n" |
325 |
> |
"Copyright (C) 1997-2004 Christian Bauer et al.\n" |
326 |
|
"E-mail: Christian.Bauer@uni-mainz.de\n" |
327 |
|
"http://www.uni-mainz.de/~bauec002/B2Main.html\n\n" |
328 |
|
"Basilisk II comes with ABSOLUTELY NO\n" |
404 |
|
create_input_pane(notebook); |
405 |
|
create_serial_pane(notebook); |
406 |
|
create_memory_pane(notebook); |
407 |
+ |
create_jit_pane(notebook); |
408 |
|
|
409 |
|
static const opt_desc buttons[] = { |
410 |
|
{STR_START_BUTTON, GTK_SIGNAL_FUNC(cb_start)}, |
582 |
|
|
583 |
|
|
584 |
|
/* |
585 |
+ |
* "JIT Compiler" pane |
586 |
+ |
*/ |
587 |
+ |
|
588 |
+ |
static GtkWidget *w_jit_fpu; |
589 |
+ |
static GtkWidget *w_jit_atraps; |
590 |
+ |
static GtkWidget *w_jit_cache_size; |
591 |
+ |
static GtkWidget *w_jit_lazy_flush; |
592 |
+ |
|
593 |
+ |
// Set sensitivity of widgets |
594 |
+ |
static void set_jit_sensitive(void) |
595 |
+ |
{ |
596 |
+ |
const bool jit_enabled = PrefsFindBool("jit"); |
597 |
+ |
gtk_widget_set_sensitive(w_jit_fpu, jit_enabled); |
598 |
+ |
gtk_widget_set_sensitive(w_jit_cache_size, jit_enabled); |
599 |
+ |
gtk_widget_set_sensitive(w_jit_lazy_flush, jit_enabled); |
600 |
+ |
} |
601 |
+ |
|
602 |
+ |
// "Use JIT Compiler" button toggled |
603 |
+ |
static void tb_jit(GtkWidget *widget) |
604 |
+ |
{ |
605 |
+ |
PrefsReplaceBool("jit", GTK_TOGGLE_BUTTON(widget)->active); |
606 |
+ |
set_jit_sensitive(); |
607 |
+ |
} |
608 |
+ |
|
609 |
+ |
// "Compile FPU Instructions" button toggled |
610 |
+ |
static void tb_jit_fpu(GtkWidget *widget) |
611 |
+ |
{ |
612 |
+ |
PrefsReplaceBool("jitfpu", GTK_TOGGLE_BUTTON(widget)->active); |
613 |
+ |
} |
614 |
+ |
|
615 |
+ |
// "Lazy translation cache invalidation" button toggled |
616 |
+ |
static void tb_jit_lazy_flush(GtkWidget *widget) |
617 |
+ |
{ |
618 |
+ |
PrefsReplaceBool("jitlazyflush", GTK_TOGGLE_BUTTON(widget)->active); |
619 |
+ |
} |
620 |
+ |
|
621 |
+ |
// Read settings from widgets and set preferences |
622 |
+ |
static void read_jit_settings(void) |
623 |
+ |
{ |
624 |
+ |
#if USE_JIT |
625 |
+ |
bool jit_enabled = PrefsFindBool("jit"); |
626 |
+ |
if (jit_enabled) { |
627 |
+ |
const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_jit_cache_size)->entry)); |
628 |
+ |
PrefsReplaceInt32("jitcachesize", atoi(str)); |
629 |
+ |
} |
630 |
+ |
#endif |
631 |
+ |
} |
632 |
+ |
|
633 |
+ |
// Create "JIT Compiler" pane |
634 |
+ |
static void create_jit_pane(GtkWidget *top) |
635 |
+ |
{ |
636 |
+ |
#if USE_JIT |
637 |
+ |
GtkWidget *box, *table, *label, *menu; |
638 |
+ |
char str[32]; |
639 |
+ |
|
640 |
+ |
box = make_pane(top, STR_JIT_PANE_TITLE); |
641 |
+ |
make_checkbox(box, STR_JIT_CTRL, "jit", GTK_SIGNAL_FUNC(tb_jit)); |
642 |
+ |
|
643 |
+ |
w_jit_fpu = make_checkbox(box, STR_JIT_FPU_CTRL, "jitfpu", GTK_SIGNAL_FUNC(tb_jit_fpu)); |
644 |
+ |
|
645 |
+ |
// Translation cache size |
646 |
+ |
static const combo_desc options[] = { |
647 |
+ |
STR_JIT_CACHE_SIZE_2MB_LAB, |
648 |
+ |
STR_JIT_CACHE_SIZE_4MB_LAB, |
649 |
+ |
STR_JIT_CACHE_SIZE_8MB_LAB, |
650 |
+ |
STR_JIT_CACHE_SIZE_16MB_LAB, |
651 |
+ |
0 |
652 |
+ |
}; |
653 |
+ |
w_jit_cache_size = make_combobox(box, STR_JIT_CACHE_SIZE_CTRL, "jitcachesize", options); |
654 |
+ |
|
655 |
+ |
// Lazy translation cache invalidation |
656 |
+ |
w_jit_lazy_flush = make_checkbox(box, STR_JIT_LAZY_CINV_CTRL, "jitlazyflush", GTK_SIGNAL_FUNC(tb_jit_lazy_flush)); |
657 |
+ |
|
658 |
+ |
set_jit_sensitive(); |
659 |
+ |
#endif |
660 |
+ |
} |
661 |
+ |
|
662 |
+ |
/* |
663 |
|
* "SCSI" pane |
664 |
|
*/ |
665 |
|
|
715 |
|
static char fbdev_name[256]; |
716 |
|
#endif |
717 |
|
|
718 |
+ |
static GtkWidget *w_dspdevice_file, *w_mixerdevice_file; |
719 |
+ |
|
720 |
|
// Hide/show graphics widgets |
721 |
|
static void hide_show_graphics_widgets(void) |
722 |
|
{ |
763 |
|
static void mn_60hz(...) {PrefsReplaceInt32("frameskip", 1);} |
764 |
|
static void mn_dynamic(...) {PrefsReplaceInt32("frameskip", 0);} |
765 |
|
|
766 |
+ |
// Set sensitivity of widgets |
767 |
+ |
static void set_graphics_sensitive(void) |
768 |
+ |
{ |
769 |
+ |
const bool sound_enabled = !PrefsFindBool("nosound"); |
770 |
+ |
gtk_widget_set_sensitive(w_dspdevice_file, sound_enabled); |
771 |
+ |
gtk_widget_set_sensitive(w_mixerdevice_file, sound_enabled); |
772 |
+ |
} |
773 |
+ |
|
774 |
|
// "Disable Sound Output" button toggled |
775 |
|
static void tb_nosound(GtkWidget *widget) |
776 |
|
{ |
777 |
|
PrefsReplaceBool("nosound", GTK_TOGGLE_BUTTON(widget)->active); |
778 |
+ |
set_graphics_sensitive(); |
779 |
|
} |
780 |
|
|
781 |
|
// Read graphics preferences |
838 |
|
else |
839 |
|
PrefsRemoveItem("fbdevicefile"); |
840 |
|
#endif |
841 |
+ |
PrefsReplaceString("dsp", get_file_entry_path(w_dspdevice_file)); |
842 |
+ |
PrefsReplaceString("mixer", get_file_entry_path(w_mixerdevice_file)); |
843 |
|
} |
844 |
|
|
845 |
|
// Create "Graphics/Sound" pane |
960 |
|
|
961 |
|
make_separator(box); |
962 |
|
make_checkbox(box, STR_NOSOUND_CTRL, "nosound", GTK_SIGNAL_FUNC(tb_nosound)); |
963 |
+ |
w_dspdevice_file = make_file_entry(box, STR_DSPDEVICE_FILE_CTRL, "dsp"); |
964 |
+ |
w_mixerdevice_file = make_file_entry(box, STR_MIXERDEVICE_FILE_CTRL, "mixer"); |
965 |
+ |
|
966 |
+ |
set_graphics_sensitive(); |
967 |
|
|
968 |
|
hide_show_graphics_widgets(); |
969 |
|
} |
1255 |
|
static GtkObject *w_ramsize_adj; |
1256 |
|
static GtkWidget *w_rom_file; |
1257 |
|
|
1258 |
+ |
// "Ignore SEGV" button toggled |
1259 |
+ |
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION |
1260 |
+ |
static void tb_ignoresegv(GtkWidget *widget) |
1261 |
+ |
{ |
1262 |
+ |
PrefsReplaceBool("ignoresegv", GTK_TOGGLE_BUTTON(widget)->active); |
1263 |
+ |
} |
1264 |
+ |
#endif |
1265 |
+ |
|
1266 |
|
// Model ID selected |
1267 |
|
static void mn_modelid_5(...) {PrefsReplaceInt32("modelid", 5);} |
1268 |
|
static void mn_modelid_14(...) {PrefsReplaceInt32("modelid", 14);} |
1365 |
|
#endif |
1366 |
|
|
1367 |
|
w_rom_file = make_file_entry(box, STR_ROM_FILE_CTRL, "rom"); |
1368 |
+ |
|
1369 |
+ |
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION |
1370 |
+ |
make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv)); |
1371 |
+ |
#endif |
1372 |
|
} |
1373 |
|
|
1374 |
|
|
1384 |
|
read_input_settings(); |
1385 |
|
read_serial_settings(); |
1386 |
|
read_memory_settings(); |
1387 |
+ |
read_jit_settings(); |
1388 |
|
} |