--- BasiliskII/src/Unix/prefs_editor_gtk.cpp 2002/01/22 17:15:10 1.21 +++ BasiliskII/src/Unix/prefs_editor_gtk.cpp 2005/01/30 21:42:14 1.26 @@ -1,7 +1,7 @@ /* * prefs_editor_gtk.cpp - Preferences editor, Unix implementation using GTK+ * - * Basilisk II (C) 1997-2002 Christian Bauer + * Basilisk II (C) 1997-2005 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,6 +52,7 @@ static void create_graphics_pane(GtkWidg static void create_input_pane(GtkWidget *top); static void create_serial_pane(GtkWidget *top); static void create_memory_pane(GtkWidget *top); +static void create_jit_pane(GtkWidget *top); static void read_settings(void); @@ -64,6 +65,10 @@ struct opt_desc { GtkSignalFunc func; }; +struct combo_desc { + int label_id; +}; + static void add_menu_item(GtkWidget *menu, int label_id, GtkSignalFunc func) { GtkWidget *item = gtk_menu_item_new_with_label(GetString(label_id)); @@ -203,7 +208,37 @@ static GtkWidget *make_checkbox(GtkWidge return button; } +static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *prefs_item, const combo_desc *options) +{ + GtkWidget *box, *label, *combo; + char str[32]; + + box = gtk_hbox_new(FALSE, 4); + gtk_widget_show(box); + gtk_box_pack_start(GTK_BOX(top), box, FALSE, FALSE, 0); + + label = gtk_label_new(GetString(label_id)); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); + + GList *glist = NULL; + while (options->label_id) { + glist = g_list_append(glist, (void *)GetString(options->label_id)); + options++; + } + + combo = gtk_combo_new(); + gtk_widget_show(combo); + gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); + + sprintf(str, "%d", PrefsFindInt32(prefs_item)); + gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str); + gtk_box_pack_start(GTK_BOX(box), combo, TRUE, TRUE, 0); + + return combo; +} + /* * Show preferences editor * Returns true when user clicked on "Start", false otherwise @@ -271,7 +306,7 @@ static void mn_about(...) dialog = gnome_about_new( "Basilisk II", version, - "Copyright (C) 1997-2002 Christian Bauer", + "Copyright (C) 1997-2004 Christian Bauer", authors, "Basilisk II comes with ABSOLUTELY NO WARRANTY." "This is free software, and you are welcome to redistribute it" @@ -287,7 +322,7 @@ static void mn_about(...) char str[512]; sprintf(str, "Basilisk II\nVersion %d.%d\n\n" - "Copyright (C) 1997-2002 Christian Bauer et al.\n" + "Copyright (C) 1997-2004 Christian Bauer et al.\n" "E-mail: Christian.Bauer@uni-mainz.de\n" "http://www.uni-mainz.de/~bauec002/B2Main.html\n\n" "Basilisk II comes with ABSOLUTELY NO\n" @@ -369,6 +404,7 @@ bool PrefsEditor(void) create_input_pane(notebook); create_serial_pane(notebook); create_memory_pane(notebook); + create_jit_pane(notebook); static const opt_desc buttons[] = { {STR_START_BUTTON, GTK_SIGNAL_FUNC(cb_start)}, @@ -546,6 +582,84 @@ static void create_volumes_pane(GtkWidge /* + * "JIT Compiler" pane + */ + +static GtkWidget *w_jit_fpu; +static GtkWidget *w_jit_atraps; +static GtkWidget *w_jit_cache_size; +static GtkWidget *w_jit_lazy_flush; + +// Set sensitivity of widgets +static void set_jit_sensitive(void) +{ + const bool jit_enabled = PrefsFindBool("jit"); + gtk_widget_set_sensitive(w_jit_fpu, jit_enabled); + gtk_widget_set_sensitive(w_jit_cache_size, jit_enabled); + gtk_widget_set_sensitive(w_jit_lazy_flush, jit_enabled); +} + +// "Use JIT Compiler" button toggled +static void tb_jit(GtkWidget *widget) +{ + PrefsReplaceBool("jit", GTK_TOGGLE_BUTTON(widget)->active); + set_jit_sensitive(); +} + +// "Compile FPU Instructions" button toggled +static void tb_jit_fpu(GtkWidget *widget) +{ + PrefsReplaceBool("jitfpu", GTK_TOGGLE_BUTTON(widget)->active); +} + +// "Lazy translation cache invalidation" button toggled +static void tb_jit_lazy_flush(GtkWidget *widget) +{ + PrefsReplaceBool("jitlazyflush", GTK_TOGGLE_BUTTON(widget)->active); +} + +// Read settings from widgets and set preferences +static void read_jit_settings(void) +{ +#if USE_JIT + bool jit_enabled = PrefsFindBool("jit"); + if (jit_enabled) { + const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_jit_cache_size)->entry)); + PrefsReplaceInt32("jitcachesize", atoi(str)); + } +#endif +} + +// Create "JIT Compiler" pane +static void create_jit_pane(GtkWidget *top) +{ +#if USE_JIT + GtkWidget *box, *table, *label, *menu; + char str[32]; + + box = make_pane(top, STR_JIT_PANE_TITLE); + make_checkbox(box, STR_JIT_CTRL, "jit", GTK_SIGNAL_FUNC(tb_jit)); + + w_jit_fpu = make_checkbox(box, STR_JIT_FPU_CTRL, "jitfpu", GTK_SIGNAL_FUNC(tb_jit_fpu)); + + // Translation cache size + static const combo_desc options[] = { + STR_JIT_CACHE_SIZE_2MB_LAB, + STR_JIT_CACHE_SIZE_4MB_LAB, + STR_JIT_CACHE_SIZE_8MB_LAB, + STR_JIT_CACHE_SIZE_16MB_LAB, + 0 + }; + w_jit_cache_size = make_combobox(box, STR_JIT_CACHE_SIZE_CTRL, "jitcachesize", options); + + // Lazy translation cache invalidation + w_jit_lazy_flush = make_checkbox(box, STR_JIT_LAZY_CINV_CTRL, "jitlazyflush", GTK_SIGNAL_FUNC(tb_jit_lazy_flush)); + + set_jit_sensitive(); +#endif +} + +/* * "SCSI" pane */ @@ -601,6 +715,8 @@ static GtkWidget *l_fbdev_name, *l_fbdev static char fbdev_name[256]; #endif +static GtkWidget *w_dspdevice_file, *w_mixerdevice_file; + // Hide/show graphics widgets static void hide_show_graphics_widgets(void) { @@ -647,10 +763,19 @@ static void mn_30hz(...) {PrefsReplaceIn static void mn_60hz(...) {PrefsReplaceInt32("frameskip", 1);} static void mn_dynamic(...) {PrefsReplaceInt32("frameskip", 0);} +// Set sensitivity of widgets +static void set_graphics_sensitive(void) +{ + const bool sound_enabled = !PrefsFindBool("nosound"); + gtk_widget_set_sensitive(w_dspdevice_file, sound_enabled); + gtk_widget_set_sensitive(w_mixerdevice_file, sound_enabled); +} + // "Disable Sound Output" button toggled static void tb_nosound(GtkWidget *widget) { PrefsReplaceBool("nosound", GTK_TOGGLE_BUTTON(widget)->active); + set_graphics_sensitive(); } // Read graphics preferences @@ -713,6 +838,8 @@ static void read_graphics_settings(void) else PrefsRemoveItem("fbdevicefile"); #endif + PrefsReplaceString("dsp", get_file_entry_path(w_dspdevice_file)); + PrefsReplaceString("mixer", get_file_entry_path(w_mixerdevice_file)); } // Create "Graphics/Sound" pane @@ -833,6 +960,10 @@ static void create_graphics_pane(GtkWidg make_separator(box); make_checkbox(box, STR_NOSOUND_CTRL, "nosound", GTK_SIGNAL_FUNC(tb_nosound)); + w_dspdevice_file = make_file_entry(box, STR_DSPDEVICE_FILE_CTRL, "dsp"); + w_mixerdevice_file = make_file_entry(box, STR_MIXERDEVICE_FILE_CTRL, "mixer"); + + set_graphics_sensitive(); hide_show_graphics_widgets(); } @@ -1124,6 +1255,14 @@ static void create_serial_pane(GtkWidget static GtkObject *w_ramsize_adj; static GtkWidget *w_rom_file; +// "Ignore SEGV" button toggled +#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION +static void tb_ignoresegv(GtkWidget *widget) +{ + PrefsReplaceBool("ignoresegv", GTK_TOGGLE_BUTTON(widget)->active); +} +#endif + // Model ID selected static void mn_modelid_5(...) {PrefsReplaceInt32("modelid", 5);} static void mn_modelid_14(...) {PrefsReplaceInt32("modelid", 14);} @@ -1226,6 +1365,10 @@ static void create_memory_pane(GtkWidget #endif w_rom_file = make_file_entry(box, STR_ROM_FILE_CTRL, "rom"); + +#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION + make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv)); +#endif } @@ -1241,4 +1384,5 @@ static void read_settings(void) read_input_settings(); read_serial_settings(); read_memory_settings(); + read_jit_settings(); }