|
|
1.1 root 1: /*
2: * UAE - the Un*x Amiga Emulator
3: *
4: * Yet Another User Interface for the X11 version
5: *
6: * Copyright 1997, 1998 Bernd Schmidt
1.1.1.2 root 7: * Copyright 1998 Michael Krause
1.1.1.18! root 8: *
1.1 root 9: * The Tk GUI doesn't work.
10: * The X Forms Library isn't available as source, and there aren't any
11: * binaries compiled against glibc
12: *
13: * So let's try this...
14: */
15:
16: #include "sysconfig.h"
17: #include "sysdeps.h"
18:
19: #include "config.h"
20: #include "options.h"
21: #include "uae.h"
22: #include "memory.h"
23: #include "custom.h"
24: #include "gui.h"
25: #include "newcpu.h"
1.1.1.11 root 26: #include "autoconf.h"
27: #include "threaddep/thread.h"
1.1.1.2 root 28: #include "sounddep/sound.h"
1.1.1.10 root 29: #include "savestate.h"
1.1.1.14 root 30: #include "debug.h"
1.1.1.18! root 31: #include "inputdevice.h"
1.1 root 32:
33: #include <gtk/gtk.h>
1.1.1.11 root 34: #include <gdk/gdk.h>
1.1 root 35:
1.1.1.4 root 36: /* One of the 1.1.6 "features" is a gratuitous name change */
37: #ifndef HAVE_GTK_FEATURES_1_1_6
38: #define gtk_container_set_border_width gtk_container_border_width
39: #endif
40: /* Likewise for 1.1.8. */
41: #ifndef HAVE_GTK_FEATURES_1_1_8
42: #define gtk_label_set_text gtk_label_set
43: #endif
1.1.1.5 root 44: /* This is beginning to suck... */
45: #ifndef HAVE_GTK_FEATURES_1_1_13
46: #define gtk_toggle_button_set_active gtk_toggle_button_set_state
47: #endif
1.1.1.4 root 48:
1.1.1.18! root 49: static int gui_active, gui_available;
1.1 root 50:
1.1.1.11 root 51: static GtkWidget *gui_window;
52:
1.1.1.10 root 53: static GtkWidget *pause_uae_widget, *snap_save_widget, *snap_load_widget;
54:
55: static GtkWidget *chipsize_widget[5];
56: static GtkWidget *bogosize_widget[4];
57: static GtkWidget *fastsize_widget[5];
58: static GtkWidget *z3size_widget[10];
59: static GtkWidget *p96size_widget[7];
1.1.1.11 root 60: static GtkWidget *rom_text_widget, *key_text_widget;
61: static GtkWidget *rom_change_widget, *key_change_widget;
1.1.1.6 root 62:
1.1 root 63: static GtkWidget *disk_insert_widget[4], *disk_eject_widget[4], *disk_text_widget[4];
64: static char *new_disk_string[4];
65:
66: static GtkAdjustment *cpuspeed_adj;
1.1.1.3 root 67: static GtkWidget *cpuspeed_widgets[4], *cpuspeed_scale;
1.1.1.18! root 68: static GtkWidget *cpu_widget[7];
! 69: #if 0
! 70: static GtkWidget *a24m_widget, *ccpu_widget;
! 71: #endif
1.1.1.9 root 72: static GtkWidget *sound_widget[4], *sound_bits_widget[2], *sound_freq_widget[3], *sound_ch_widget[3];
1.1 root 73:
1.1.1.10 root 74: static GtkWidget *coll_widget[4], *cslevel_widget[4];
75: static GtkWidget *fcop_widget;
76:
1.1 root 77: static GtkAdjustment *framerate_adj;
1.1.1.18! root 78: static GtkWidget *bimm_widget, *showleds_widget, *b32_widget, *afscr_widget, *pfscr_widget;
1.1 root 79:
1.1.1.18! root 80: static GtkWidget *joy_widget[2][6], *legacy_widget;
1.1 root 81:
82: static GtkWidget *led_widgets[5];
83: static GdkColor led_on[5], led_off[5];
84: static unsigned int prevledstate;
85:
1.1.1.11 root 86: static GtkWidget *hdlist_widget;
87: static int selected_hd_row;
88: static GtkWidget *hdchange_button, *hddel_button;
89: static GtkWidget *volname_entry, *path_entry;
90: static GtkWidget *dirdlg;
91: static char dirdlg_volname[256], dirdlg_path[256];
92:
1.1.1.14 root 93: static GtkWidget *lab_info;
1.1.1.15 root 94: static GtkWidget *notebook;
1.1.1.14 root 95:
1.1.1.2 root 96: static smp_comm_pipe to_gui_pipe, from_gui_pipe;
1.1.1.18! root 97:
! 98: /*
! 99: * Messages sent to GUI from UAE via to_gui_pipe
! 100: */
! 101: enum gui_commands {
! 102: GUICMD_SHOW, // Show yourself
! 103: GUICMD_UPDATE, // Refresh your state from changed preferences
! 104: GUICMD_DISKCHANGE, // Hey! A disk has been changed. Do something!
! 105: GUICMD_MSGBOX, // Display a message box for me, please
! 106: GUICMD_FLOPPYDLG, // Open a floppy insert dialog
! 107: GUICMD_PAUSE, // We're now paused, in case you didn't notice
! 108: GUICMD_UNPAUSE // We're now running.
! 109: };
! 110:
1.1.1.11 root 111: static uae_sem_t gui_sem, gui_init_sem, gui_quit_sem; /* gui_sem protects the DFx fields */
1.1.1.2 root 112:
113: static volatile int quit_gui = 0, quitted_gui = 0;
114:
1.1.1.18! root 115: /* Message box functions. */
! 116:
! 117:
! 118: static GtkWidget *make_labelled_button (guchar *label, GtkAccelGroup *accel_group)
! 119: {
! 120: return gtk_button_new_with_mnemonic (label);
! 121: }
! 122:
! 123: /*
! 124: * on_message_box_quit()
! 125: *
! 126: * Handler called when message box is exited. Signals anybody that cares
! 127: * via the semaphore it is supplied.
! 128: */
! 129: static void on_message_box_quit (GtkWidget *w, gpointer user_data)
! 130: {
! 131: uae_sem_post ((uae_sem_t *)user_data);
! 132: }
! 133:
! 134: /*
! 135: * make_message_box()
! 136: *
! 137: * This does the actual work of constructing the message dialog.
! 138: *
! 139: * title - displayed in the dialog's titlebar
! 140: * message - the message itself
! 141: * modal - whether the dialog should block input to the rest of the GUI
! 142: * sem - semaphore used for signalling that the dialog's finished
! 143: *
! 144: * TODO: Make that semaphore go away. We shouldn't need to know about it here.
! 145: */
! 146: #define PACKAGE_NAME "UAE"
! 147:
! 148: static GtkWidget *make_message_box (const guchar *title, const guchar *message, int modal, uae_sem_t *sem)
! 149: {
! 150: GtkWidget *dialog;
! 151: GtkWidget *vbox;
! 152: GtkWidget *label;
! 153: GtkWidget *hseparator;
! 154: GtkWidget *hbuttonbox;
! 155: GtkWidget *button;
! 156: guint key;
! 157: GtkAccelGroup *accel_group;
! 158:
! 159: accel_group = gtk_accel_group_new ();
! 160:
! 161: dialog = gtk_window_new ( GTK_WINDOW_TOPLEVEL /*GTK_WINDOW_DIALOG*/);
! 162: gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);
! 163: if (title==NULL || (title!=NULL && strlen(title)==0))
! 164: title = PACKAGE_NAME " information";
! 165: gtk_window_set_title (GTK_WINDOW (dialog), title);
! 166: gtk_window_set_modal (GTK_WINDOW (dialog), modal);
! 167: gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
! 168:
! 169: vbox = gtk_vbox_new (FALSE, 0);
! 170: gtk_widget_show (vbox);
! 171: gtk_container_add (GTK_CONTAINER (dialog), vbox);
! 172:
! 173: label = gtk_label_new (message);
! 174: gtk_widget_show (label);
! 175: gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
! 176: gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
! 177:
! 178: hseparator = gtk_hseparator_new ();
! 179: gtk_widget_show (hseparator);
! 180: gtk_box_pack_start (GTK_BOX (vbox), hseparator, FALSE, FALSE, 8);
! 181:
! 182: hbuttonbox = gtk_hbutton_box_new ();
! 183: gtk_widget_show (hbuttonbox);
! 184: gtk_box_pack_start (GTK_BOX (vbox), hbuttonbox, FALSE, FALSE, 0);
! 185: gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_END);
! 186: gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox), 4);
! 187:
! 188: button = make_labelled_button ("_Okay", accel_group);
! 189: gtk_widget_show (button);
! 190: gtk_container_add (GTK_CONTAINER (hbuttonbox), button);
! 191: GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
! 192:
! 193: if (sem)
! 194: gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (on_message_box_quit), sem);
! 195: gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
! 196: GTK_SIGNAL_FUNC (gtk_widget_destroy),
! 197: GTK_OBJECT (dialog));
! 198:
! 199: gtk_widget_grab_default (button);
! 200: gtk_window_add_accel_group (GTK_WINDOW (dialog), accel_group);
! 201: gtk_widget_show( dialog );
! 202:
! 203: return dialog;
! 204: }
! 205:
! 206:
! 207: /*
! 208: * handle_message_box_request()
! 209: *
! 210: * This is called from the GUI's context in repsonse to do_message_box()
! 211: * to actually create the dialog box
! 212: */
! 213: static void handle_message_box_request (smp_comm_pipe *msg_pipe)
! 214: {
! 215: const guchar *title = (const guchar *) read_comm_pipe_pvoid_blocking (msg_pipe);
! 216: const guchar *msg = (const guchar *) read_comm_pipe_pvoid_blocking (msg_pipe);
! 217: int modal = read_comm_pipe_int_blocking (msg_pipe);
! 218: uae_sem_t *msg_quit_sem = (uae_sem_t *) read_comm_pipe_pvoid_blocking (msg_pipe);
! 219:
! 220: GtkWidget *dialog = make_message_box (title, msg, modal, msg_quit_sem);
! 221: }
! 222:
! 223: /*
! 224: * do_message_box()
! 225: *
! 226: * This makes up for GTK's lack of a function for creating simple message dialogs.
! 227: * It can be called from any context. gui_init() must have been called at some point
! 228: * previously.
! 229: *
! 230: * title - will be displayed in the dialog's titlebar (or NULL for default)
! 231: * message - the message itself
! 232: * modal - should the dialog block input to the rest of the GUI
! 233: * wait - should the dialog wait until the user has acknowledged it
! 234: */
! 235: static void do_message_box( const guchar *title, const guchar *message, gboolean modal, gboolean wait )
! 236: {
! 237: uae_sem_t msg_quit_sem;
! 238:
! 239: // If we a need reply, then this semaphore which will be used
! 240: // to signal us when the dialog has been exited.
! 241: uae_sem_init (&msg_quit_sem, 0, 0);
! 242:
! 243: write_comm_pipe_int (&to_gui_pipe, GUICMD_MSGBOX, 0);
! 244: write_comm_pipe_pvoid (&to_gui_pipe, (void *) title, 0);
! 245: write_comm_pipe_pvoid (&to_gui_pipe, (void *) message, 0);
! 246: write_comm_pipe_int (&to_gui_pipe, (int) modal, 0);
! 247: write_comm_pipe_pvoid (&to_gui_pipe, wait?&msg_quit_sem:NULL, 1);
! 248:
! 249: if (wait)
! 250: uae_sem_wait (&msg_quit_sem);
! 251: }
! 252:
! 253: void gui_message (const char *format,...)
! 254: {
! 255: char msg[2048];
! 256: va_list parms;
! 257:
! 258: va_start (parms,format);
! 259: vsprintf ( msg, format, parms);
! 260: va_end (parms);
! 261:
! 262: if (gui_available)
! 263: do_message_box (NULL, msg, TRUE, TRUE);
! 264:
! 265: write_log (msg);
! 266: }
! 267:
! 268: /* Config save/load. */
! 269:
1.1 root 270: static void save_config (void)
271: {
272: FILE *f;
273: char tmp[257];
274:
275: /* Backup the options file. */
276: strcpy (tmp, optionsfile);
277: strcat (tmp, "~");
278: rename (optionsfile, tmp);
279:
280: f = fopen (optionsfile, "w");
281: if (f == NULL) {
1.1.1.13 root 282: write_log ("Error saving options file!\n");
1.1 root 283: return;
284: }
1.1.1.4 root 285: save_options (f, &currprefs);
1.1 root 286: fclose (f);
287: }
288:
289: static int nr_for_led (GtkWidget *led)
290: {
291: int i;
292: i = 0;
293: while (led_widgets[i] != led)
294: i++;
295: return i;
296: }
297:
298: static void enable_disk_buttons (int enable)
299: {
300: int i;
301: for (i = 0; i < 4; i++) {
302: gtk_widget_set_sensitive (disk_insert_widget[i], enable);
303: gtk_widget_set_sensitive (disk_eject_widget[i], enable);
304: }
305: }
306:
1.1.1.10 root 307: static void enable_snap_buttons (int enable)
308: {
309: gtk_widget_set_sensitive (snap_save_widget, enable);
310: gtk_widget_set_sensitive (snap_load_widget, enable);
311: }
312:
1.1 root 313: static void set_cpu_state (void)
314: {
1.1.1.10 root 315: int i;
1.1.1.18! root 316: #if 0
1.1.1.5 root 317: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (a24m_widget), changed_prefs.address_space_24 != 0);
1.1.1.8 root 318: gtk_widget_set_sensitive (a24m_widget, changed_prefs.cpu_level > 1 && changed_prefs.cpu_level < 4);
1.1.1.5 root 319: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ccpu_widget), changed_prefs.cpu_compatible != 0);
1.1 root 320: gtk_widget_set_sensitive (ccpu_widget, changed_prefs.cpu_level == 0);
1.1.1.18! root 321: #endif
1.1.1.3 root 322: gtk_widget_set_sensitive (cpuspeed_scale, changed_prefs.m68k_speed > 0);
1.1.1.10 root 323: for (i = 0; i < 10; i++)
1.1.1.18! root 324: gtk_widget_set_sensitive (z3size_widget[i], ! changed_prefs.address_space_24);
! 325: for (i = 0; i < 7; i++)
! 326: gtk_widget_set_sensitive (p96size_widget[i], ! changed_prefs.address_space_24);
1.1 root 327: }
328:
329: static void set_cpu_widget (void)
330: {
331: int nr = changed_prefs.cpu_level;
1.1.1.10 root 332:
1.1.1.18! root 333: if (nr > 3)
! 334: nr += 2;
! 335: else if (nr >= 2 && changed_prefs.address_space_24)
! 336: nr += 2;
1.1.1.5 root 337: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cpu_widget[nr]), TRUE);
1.1.1.3 root 338: nr = currprefs.m68k_speed + 1 < 3 ? currprefs.m68k_speed + 1 : 2;
1.1.1.5 root 339: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cpuspeed_widgets[nr]), TRUE);
1.1.1.10 root 340:
1.1 root 341: }
342:
343: static void set_gfx_state (void)
344: {
1.1.1.5 root 345: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bimm_widget), currprefs.immediate_blits != 0);
1.1.1.18! root 346: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (showleds_widget), currprefs.leds_on_screen != 0);
1.1.1.10 root 347: #if 0
1.1.1.5 root 348: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b32_widget), currprefs.blits_32bit_enabled != 0);
1.1.1.7 root 349: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (afscr_widget), currprefs.gfx_afullscreen != 0);
350: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pfscr_widget), currprefs.gfx_pfullscreen != 0);
1.1.1.10 root 351: #endif
352: }
353:
354: static void set_chipset_state (void)
355: {
356: int t0 = 0;
357: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (coll_widget[currprefs.collision_level]), TRUE);
358: if (currprefs.chipset_mask & CSMASK_AGA)
359: t0 = 3;
360: else if (currprefs.chipset_mask & CSMASK_ECS_DENISE)
361: t0 = 2;
362: else if (currprefs.chipset_mask & CSMASK_ECS_AGNUS)
363: t0 = 1;
364: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cslevel_widget[t0]), TRUE);
1.1 root 365: }
366:
1.1.1.2 root 367: static void set_sound_state (void)
368: {
1.1.1.16 root 369: int stereo = currprefs.sound_stereo + currprefs.mixed_stereo;
1.1.1.5 root 370: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sound_widget[currprefs.produce_sound]), 1);
1.1.1.9 root 371: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sound_ch_widget[stereo]), 1);
1.1.1.5 root 372: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sound_bits_widget[currprefs.sound_bits == 16]), 1);
1.1.1.2 root 373: }
374:
1.1.1.10 root 375: static void set_mem_state (void)
376: {
377: int t, t2;
378:
379: t = 0;
380: t2 = currprefs.chipmem_size;
381: while (t < 4 && t2 > 0x80000)
382: t++, t2 >>= 1;
383: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chipsize_widget[t]), 1);
384:
385: t = 0;
386: t2 = currprefs.bogomem_size;
387: while (t < 3 && t2 >= 0x80000)
388: t++, t2 >>= 1;
389: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bogosize_widget[t]), 1);
390:
391: t = 0;
392: t2 = currprefs.fastmem_size;
393: while (t < 4 && t2 >= 0x100000)
394: t++, t2 >>= 1;
395: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fastsize_widget[t]), 1);
396:
397: t = 0;
398: t2 = currprefs.z3fastmem_size;
399: while (t < 9 && t2 >= 0x100000)
400: t++, t2 >>= 1;
401: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (z3size_widget[t]), 1);
402:
403: t = 0;
404: t2 = currprefs.gfxmem_size;
405: while (t < 6 && t2 >= 0x100000)
406: t++, t2 >>= 1;
407: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (p96size_widget[t]), 1);
1.1.1.11 root 408:
409: gtk_label_set_text (GTK_LABEL (rom_text_widget), currprefs.romfile);
410: gtk_label_set_text (GTK_LABEL (key_text_widget), currprefs.keyfile);
1.1.1.10 root 411: }
412:
1.1 root 413: static void set_joy_state (void)
414: {
1.1.1.18! root 415: int joy_count = inputdevice_get_device_total (IDTYPE_JOYSTICK);
! 416: int j0j = jsem_isjoy (0, &changed_prefs);
! 417: int j0m = jsem_ismouse (0, &changed_prefs);
! 418: int j0k = jsem_iskbdjoy (0, &changed_prefs);
! 419: int j1j = jsem_isjoy (1, &changed_prefs);
! 420: int j1m = jsem_ismouse (1, &changed_prefs);
! 421: int j1k = jsem_iskbdjoy (1, &changed_prefs);
! 422: int j0t = (j0j == 0 || j0j == 1 ? j0j
! 423: : j0m == 0 ? 2
! 424: : j0k + 3);
! 425: int j1t = (j1j == 0 || j1j == 1 ? j1j
! 426: : j1m == 0 ? 2
! 427: : j1k + 3);
1.1 root 428: int i;
429:
430: if (j0t == j1t) {
431: /* Can't happen */
432: j0t++;
433: j0t %= 6;
434: }
1.1.1.18! root 435:
1.1 root 436: for (i = 0; i < 6; i++) {
1.1.1.18! root 437: int available = i >= 2 || joy_count > i;
! 438: if (changed_prefs.input_selected_setting != 0)
! 439: available = 0;
1.1.1.5 root 440: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (joy_widget[0][i]), j0t == i);
441: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (joy_widget[1][i]), j1t == i);
1.1.1.18! root 442: gtk_widget_set_sensitive (joy_widget[0][i], available && j1t != i);
! 443: gtk_widget_set_sensitive (joy_widget[1][i], available && j0t != i);
1.1 root 444: }
1.1.1.18! root 445:
! 446: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (legacy_widget),
! 447: changed_prefs.input_selected_setting == 0);
1.1 root 448: }
449:
1.1.1.11 root 450: static void set_hd_state (void)
451: {
452: char texts[9][256];
453: char *tptrs[] = { texts[0], texts[1], texts[2], texts[3], texts[4], texts[5], texts[6], texts[7], texts[8] };
454: int nr = nr_units (currprefs.mountinfo);
455: int i;
456:
457: gtk_clist_freeze (GTK_CLIST (hdlist_widget));
458: gtk_clist_clear (GTK_CLIST (hdlist_widget));
459: for (i = 0; i < nr; i++) {
460: int secspertrack, surfaces, reserved, blocksize, size;
461: int cylinders, readonly;
462: char *volname, *rootdir;
463: char *failure;
464:
465: /* We always use currprefs.mountinfo for the GUI. The filesystem
466: code makes a private copy which is updated every reset. */
467: failure = get_filesys_unit (currprefs.mountinfo, i,
468: &volname, &rootdir, &readonly,
469: &secspertrack, &surfaces, &reserved,
470: &cylinders, &size, &blocksize);
1.1.1.18! root 471:
1.1.1.11 root 472: if (is_hardfile (currprefs.mountinfo, i)) {
473: sprintf (texts[0], "DH%d", i );
474: sprintf (texts[3], "%d", surfaces);
475: sprintf (texts[4], "%d", cylinders);
476: sprintf (texts[5], "%d", secspertrack);
477: sprintf (texts[6], "%d", reserved);
478: sprintf (texts[7], "%d", size);
479: sprintf (texts[8], "%d", blocksize);
480: } else {
481: strcpy (texts[0], volname);
482: strcpy (texts[3], "n/a");
483: strcpy (texts[4], "n/a");
484: strcpy (texts[5], "n/a");
485: strcpy (texts[6], "n/a");
486: strcpy (texts[7], "n/a");
487: strcpy (texts[8], "n/a");
488: }
489: strcpy (texts[1], rootdir);
490: strcpy (texts[2], readonly ? "y" : "n");
491: gtk_clist_append (GTK_CLIST (hdlist_widget), tptrs);
492: }
493: gtk_clist_thaw (GTK_CLIST (hdlist_widget));
494: gtk_widget_set_sensitive (hdchange_button, FALSE);
495: gtk_widget_set_sensitive (hddel_button, FALSE);
496: }
497:
1.1 root 498: static void draw_led (int nr)
499: {
500: GtkWidget *thing = led_widgets[nr];
501: GdkWindow *window = thing->window;
502: GdkGC *gc = gdk_gc_new (window);
503: GdkColor *col;
504:
505: if (gui_ledstate & (1 << nr))
506: col = led_on + nr;
507: else
508: col = led_off + nr;
509: gdk_gc_set_foreground (gc, col);
510: gdk_draw_rectangle (window, gc, 1, 0, 0, -1, -1);
511: gdk_gc_destroy (gc);
512: }
513:
514: static int my_idle (void)
515: {
516: unsigned int leds = gui_ledstate;
517: int i;
518:
519: if (quit_gui) {
520: gtk_main_quit ();
521: goto out;
522: }
523: while (comm_pipe_has_data (&to_gui_pipe)) {
524: int cmd = read_comm_pipe_int_blocking (&to_gui_pipe);
525: int n;
526: switch (cmd) {
1.1.1.18! root 527: case GUICMD_DISKCHANGE:
1.1 root 528: n = read_comm_pipe_int_blocking (&to_gui_pipe);
1.1.1.4 root 529: gtk_label_set_text (GTK_LABEL (disk_text_widget[n]), currprefs.df[n]);
1.1 root 530: break;
1.1.1.18! root 531: case GUICMD_UPDATE:
1.1 root 532: /* Initialization. */
533: set_cpu_widget ();
534: set_cpu_state ();
535: set_gfx_state ();
536: set_joy_state ();
1.1.1.2 root 537: set_sound_state ();
1.1.1.10 root 538: set_mem_state ();
1.1.1.11 root 539: set_hd_state ();
1.1.1.10 root 540: set_chipset_state ();
1.1.1.3 root 541:
1.1.1.11 root 542: gtk_widget_show (gui_window);
543: uae_sem_post (&gui_init_sem);
1.1 root 544: gui_active = 1;
545: break;
1.1.1.18! root 546: case GUICMD_PAUSE:
1.1.1.14 root 547: /* Set Pause-Button active */
548: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pause_uae_widget), TRUE);
549: break;
1.1.1.18! root 550: case GUICMD_UNPAUSE:
1.1.1.14 root 551: /* Set Pause-Button inactive */
552: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pause_uae_widget), FALSE);
553: break;
1.1.1.18! root 554: case GUICMD_MSGBOX:
! 555: handle_message_box_request(&to_gui_pipe);
! 556: break;
1.1 root 557: }
558: }
1.1.1.10 root 559:
1.1.1.15 root 560: if (gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)) == 0) {
561: for (i = 0; i < 5; i++) {
562: unsigned int mask = 1 << i;
563: unsigned int on = leds & mask;
564:
565: if (on == (prevledstate & mask))
566: continue;
567:
568: /* printf(": %d %d\n", i, on);*/
569: draw_led (i);
1.1.1.18! root 570: }
1.1.1.15 root 571: prevledstate = leds;
1.1 root 572: }
1.1.1.15 root 573: out:
1.1 root 574: return 1;
575: }
576:
1.1.1.2 root 577: static int find_current_toggle (GtkWidget **widgets, int count)
578: {
579: int i;
580: for (i = 0; i < count; i++)
581: if (GTK_TOGGLE_BUTTON (*widgets++)->active)
582: return i;
1.1.1.13 root 583: write_log ("GTKUI: Can't happen!\n");
1.1.1.2 root 584: return -1;
585: }
586:
1.1 root 587: static void joy_changed (void)
588: {
1.1.1.18! root 589: int j0t, j1t;
1.1 root 590: if (! gui_active)
591: return;
592:
1.1.1.18! root 593: j0t = find_current_toggle (joy_widget[0], 6);
! 594: j1t = find_current_toggle (joy_widget[1], 6);
! 595: changed_prefs.jport0 = (j0t == 0 || j0t == 1 ? JSEM_JOYS + j0t
! 596: : j0t == 2 ? JSEM_MICE
! 597: : JSEM_KBDLAYOUT + j0t - 3);
! 598: changed_prefs.jport1 = (j1t == 0 || j1t == 1 ? JSEM_JOYS + j1t
! 599: : j1t == 2 ? JSEM_MICE
! 600: : JSEM_KBDLAYOUT + j1t - 3);
! 601:
! 602: changed_prefs.input_selected_setting = GTK_TOGGLE_BUTTON (legacy_widget)->active ? 0 : 1;
! 603:
! 604: if (changed_prefs.input_selected_setting != currprefs.input_selected_setting
! 605: || changed_prefs.jport0 != currprefs.jport0
! 606: || changed_prefs.jport1 != currprefs.jport1)
! 607: inputdevice_config_change ();
! 608:
1.1 root 609: set_joy_state ();
610: }
611:
1.1.1.10 root 612: static void coll_changed (void)
613: {
614: changed_prefs.collision_level = find_current_toggle (coll_widget, 4);
615: }
616:
617: static void cslevel_changed (void)
618: {
619: int t = find_current_toggle (cslevel_widget, 4);
620: int t1 = 0;
621: if (t > 0)
622: t1 |= CSMASK_ECS_AGNUS;
623: if (t > 1)
624: t1 |= CSMASK_ECS_DENISE;
625: if (t > 2)
626: t1 |= CSMASK_AGA;
627: changed_prefs.chipset_mask = t1;
628: }
629:
1.1.1.2 root 630: static void custom_changed (void)
1.1 root 631: {
1.1.1.6 root 632: changed_prefs.gfx_framerate = framerate_adj->value;
1.1 root 633: changed_prefs.immediate_blits = GTK_TOGGLE_BUTTON (bimm_widget)->active;
1.1.1.18! root 634: changed_prefs.leds_on_screen = GTK_TOGGLE_BUTTON (showleds_widget)->active;
1.1.1.10 root 635: #if 0
636: changed_prefs.blits_32bit_enabled = GTK_TOGGLE_BUTTON (b32_widget)->active;
1.1.1.7 root 637: changed_prefs.gfx_afullscreen = GTK_TOGGLE_BUTTON (afscr_widget)->active;
638: changed_prefs.gfx_pfullscreen = GTK_TOGGLE_BUTTON (pfscr_widget)->active;
1.1.1.10 root 639: #endif
1.1 root 640: }
641:
642: static void cpuspeed_changed (void)
643: {
1.1.1.3 root 644: int which = find_current_toggle (cpuspeed_widgets, 3);
645: changed_prefs.m68k_speed = (which == 0 ? -1
646: : which == 1 ? 0
647: : cpuspeed_adj->value);
648: set_cpu_state ();
1.1 root 649: }
650:
651: static void cputype_changed (void)
652: {
653: int i, oldcl;
1.1.1.18! root 654: int whichtoggle;
1.1 root 655: if (! gui_active)
656: return;
657:
658: oldcl = changed_prefs.cpu_level;
659:
1.1.1.18! root 660: whichtoggle = find_current_toggle (cpu_widget, 7);
! 661: if (whichtoggle >= 6) {
! 662: whichtoggle -= 2;
! 663: changed_prefs.address_space_24 = 0;
! 664: } else if (whichtoggle >= 4) {
! 665: changed_prefs.address_space_24 = 1;
! 666: whichtoggle -= 2;
! 667: } else
! 668: changed_prefs.address_space_24 = whichtoggle < 2;
! 669: changed_prefs.cpu_level = whichtoggle;
! 670: #if 0
1.1 root 671: changed_prefs.cpu_compatible = GTK_TOGGLE_BUTTON (ccpu_widget)->active;
672:
673: if (changed_prefs.cpu_level != 0)
674: changed_prefs.cpu_compatible = 0;
1.1.1.18! root 675: #endif
1.1.1.8 root 676:
1.1 root 677: set_cpu_state ();
678: }
679:
1.1.1.10 root 680: static void chipsize_changed (void)
681: {
682: int t = find_current_toggle (chipsize_widget, 5);
683: changed_prefs.chipmem_size = 0x80000 << t;
684: for (t = 0; t < 5; t++)
685: gtk_widget_set_sensitive (fastsize_widget[t], changed_prefs.chipmem_size <= 0x200000);
686: if (changed_prefs.chipmem_size > 0x200000) {
687: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fastsize_widget[0]), 1);
688: changed_prefs.fastmem_size = 0;
689: }
690: }
691:
692: static void bogosize_changed (void)
693: {
694: int t = find_current_toggle (bogosize_widget, 4);
695: changed_prefs.bogomem_size = (0x40000 << t) & ~0x40000;
696: }
697:
698: static void fastsize_changed (void)
699: {
700: int t = find_current_toggle (fastsize_widget, 5);
701: changed_prefs.fastmem_size = (0x80000 << t) & ~0x80000;
702: }
703:
704: static void z3size_changed (void)
705: {
706: int t = find_current_toggle (z3size_widget, 10);
707: changed_prefs.z3fastmem_size = (0x80000 << t) & ~0x80000;
708: }
709:
710: static void p96size_changed (void)
711: {
712: int t = find_current_toggle (p96size_widget, 7);
713: changed_prefs.gfxmem_size = (0x80000 << t) & ~0x80000;
714: }
715:
1.1.1.2 root 716: static void sound_changed (void)
717: {
718: changed_prefs.produce_sound = find_current_toggle (sound_widget, 4);
1.1.1.16 root 719: changed_prefs.sound_stereo = find_current_toggle (sound_ch_widget, 3);
1.1.1.9 root 720: changed_prefs.mixed_stereo = 0;
1.1.1.16 root 721: if (changed_prefs.sound_stereo == 2)
722: changed_prefs.mixed_stereo = changed_prefs.sound_stereo = 1;
1.1.1.2 root 723: changed_prefs.sound_bits = (find_current_toggle (sound_bits_widget, 2) + 1) * 8;
724: }
725:
1.1 root 726: static void did_reset (void)
727: {
728: if (quit_gui)
729: return;
1.1.1.18! root 730:
1.1 root 731: write_comm_pipe_int (&from_gui_pipe, 2, 1);
732: }
733:
734: static void did_debug (void)
735: {
736: if (quit_gui)
737: return;
1.1.1.14 root 738:
1.1 root 739: write_comm_pipe_int (&from_gui_pipe, 3, 1);
740: }
741:
742: static void did_quit (void)
743: {
744: if (quit_gui)
745: return;
1.1.1.14 root 746:
1.1 root 747: write_comm_pipe_int (&from_gui_pipe, 4, 1);
748: }
749:
1.1.1.2 root 750: static void did_eject (GtkWidget *w, gpointer data)
751: {
1.1 root 752: if (quit_gui)
753: return;
1.1.1.14 root 754:
1.1 root 755: write_comm_pipe_int (&from_gui_pipe, 0, 0);
1.1.1.2 root 756: write_comm_pipe_int (&from_gui_pipe, (int)data, 1);
1.1.1.14 root 757: gtk_label_set_text (GTK_LABEL (disk_text_widget[(int)data]), "");
1.1 root 758: }
759:
1.1.1.14 root 760: static void pause_uae (void)
1.1.1.6 root 761: {
762: if (quit_gui)
763: return;
764:
1.1.1.14 root 765: write_comm_pipe_int (&from_gui_pipe, GTK_TOGGLE_BUTTON (pause_uae_widget)->active ? 5 : 6, 1);
766: if (! GTK_TOGGLE_BUTTON (pause_uae_widget)->active)
767: gtk_widget_hide (lab_info);
1.1.1.6 root 768: }
769:
770: static void end_pause_uae (void)
771: {
1.1.1.18! root 772: write_comm_pipe_int (&to_gui_pipe, GUICMD_UNPAUSE, 1);
1.1.1.6 root 773: }
1.1.1.18! root 774:
1.1 root 775: static int filesel_active = -1;
1.1.1.10 root 776: static GtkWidget *disk_selector;
777:
778: static int snapsel_active = -1;
1.1.1.11 root 779: static char *gui_snapname, *gui_romname, *gui_keyname;
1.1 root 780:
1.1.1.11 root 781: static void did_close_insert (gpointer data)
1.1 root 782: {
783: filesel_active = -1;
784: enable_disk_buttons (1);
785: }
786:
787: static void did_insert_select (GtkObject *o)
788: {
1.1.1.18! root 789: const char *s = gtk_file_selection_get_filename (GTK_FILE_SELECTION (disk_selector));
1.1.1.13 root 790: printf ("%d %s\n", filesel_active, s);
1.1 root 791: if (quit_gui)
792: return;
793:
794: uae_sem_wait (&gui_sem);
795: if (new_disk_string[filesel_active] != 0)
796: free (new_disk_string[filesel_active]);
797: new_disk_string[filesel_active] = strdup (s);
798: uae_sem_post (&gui_sem);
799: write_comm_pipe_int (&from_gui_pipe, 1, 0);
800: write_comm_pipe_int (&from_gui_pipe, filesel_active, 1);
1.1.1.14 root 801: gtk_label_set_text (GTK_LABEL (disk_text_widget[filesel_active]), strdup (s));
1.1 root 802: filesel_active = -1;
803: enable_disk_buttons (1);
1.1.1.11 root 804: gtk_widget_destroy (disk_selector);
1.1 root 805: }
806:
807: static char fsbuffer[100];
808:
1.1.1.11 root 809: static GtkWidget *make_file_selector (const char *title,
810: void (*insertfunc)(GtkObject *),
811: void (*closefunc)(gpointer))
812: {
813: GtkWidget *p = gtk_file_selection_new (title);
814: gtk_signal_connect (GTK_OBJECT (p), "destroy", (GtkSignalFunc) closefunc, p);
815:
816: gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (p)->ok_button),
817: "clicked", (GtkSignalFunc) insertfunc,
818: GTK_OBJECT (p));
819: gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (p)->cancel_button),
820: "clicked", (GtkSignalFunc) gtk_widget_destroy,
821: GTK_OBJECT (p));
822:
823: #if 0
824: gtk_window_set_title (GTK_WINDOW (p), title);
825: #endif
826:
827: gtk_widget_show (p);
828: return p;
829: }
830:
831: static void filesel_set_path (GtkWidget *p, const char *path)
832: {
833: size_t len = strlen (path);
834: if (len > 0 && ! access (path, R_OK)) {
835: char *tmp = xmalloc (len + 2);
836: strcpy (tmp, path);
837: strcat (tmp, "/");
838: gtk_file_selection_set_filename (GTK_FILE_SELECTION (p),
839: tmp);
840: }
841: }
842:
1.1.1.2 root 843: static void did_insert (GtkWidget *w, gpointer data)
1.1 root 844: {
1.1.1.2 root 845: int n = (int)data;
1.1 root 846: if (filesel_active != -1)
847: return;
848: filesel_active = n;
849: enable_disk_buttons (0);
850:
851: sprintf (fsbuffer, "Select a disk image file for DF%d", n);
1.1.1.11 root 852: disk_selector = make_file_selector (fsbuffer, did_insert_select, did_close_insert);
853: filesel_set_path (disk_selector, currprefs.path_floppy);
1.1 root 854: }
855:
856: static gint driveled_event (GtkWidget *thing, GdkEvent *event)
857: {
858: int lednr = nr_for_led (thing);
859:
860: switch (event->type) {
861: case GDK_MAP:
862: draw_led (lednr);
863: break;
864: case GDK_EXPOSE:
865: draw_led (lednr);
866: break;
867: default:
868: break;
869: }
870:
871: return 0;
872: }
873:
1.1.1.11 root 874: static GtkWidget *snap_selector;
1.1.1.10 root 875:
1.1.1.11 root 876: static void did_close_snap (gpointer gdata)
1.1.1.10 root 877: {
878: snapsel_active = -1;
879: enable_snap_buttons (1);
880: }
881:
882: static void did_snap_select (GtkObject *o)
883: {
1.1.1.18! root 884: const char *s = gtk_file_selection_get_filename (GTK_FILE_SELECTION (snap_selector));
1.1.1.11 root 885:
1.1.1.10 root 886: if (quit_gui)
887: return;
888:
889: uae_sem_wait (&gui_sem);
890: gui_snapname = strdup (s);
891: uae_sem_post (&gui_sem);
892: write_comm_pipe_int (&from_gui_pipe, 7, 0);
893: write_comm_pipe_int (&from_gui_pipe, snapsel_active, 1);
894: snapsel_active = -1;
895: enable_snap_buttons (1);
1.1.1.11 root 896: gtk_widget_destroy (snap_selector);
1.1.1.10 root 897: }
898:
899: static void did_loadstate (void)
900: {
901: if (snapsel_active != -1)
902: return;
903: snapsel_active = STATE_DORESTORE;
904: enable_snap_buttons (0);
905:
1.1.1.11 root 906: snap_selector = make_file_selector ("Select a state file to restore",
907: did_snap_select, did_close_snap);
1.1.1.10 root 908: }
909:
910: static void did_savestate (void)
911: {
912: if (snapsel_active != -1)
913: return;
914: snapsel_active = STATE_DOSAVE;
915: enable_snap_buttons (0);
916:
1.1.1.11 root 917: snap_selector = make_file_selector ("Select a filename for the state file",
918: did_snap_select, did_close_snap);
919: }
920:
921: static GtkWidget *rom_selector;
922:
923: static void did_close_rom (gpointer gdata)
924: {
925: gtk_widget_set_sensitive (rom_change_widget, 1);
926: }
927:
928: static void did_rom_select (GtkObject *o)
929: {
1.1.1.18! root 930: const char *s = gtk_file_selection_get_filename (GTK_FILE_SELECTION (rom_selector));
1.1.1.11 root 931:
932: if (quit_gui)
933: return;
934:
935: gtk_widget_set_sensitive (rom_change_widget, 1);
936:
937: uae_sem_wait (&gui_sem);
938: gui_romname = strdup (s);
939: uae_sem_post (&gui_sem);
940: write_comm_pipe_int (&from_gui_pipe, 8, 0);
941: gtk_label_set_text (GTK_LABEL (rom_text_widget), gui_romname);
942: gtk_widget_destroy (rom_selector);
943: }
944:
945: static void did_romchange (GtkWidget *w, gpointer data)
946: {
947: gtk_widget_set_sensitive (rom_change_widget, 0);
948:
949: rom_selector = make_file_selector ("Select a ROM file",
950: did_rom_select, did_close_rom);
951: filesel_set_path (rom_selector, currprefs.path_rom);
952: }
953:
954: static GtkWidget *key_selector;
1.1.1.10 root 955:
1.1.1.11 root 956: static void did_close_key (gpointer gdata)
957: {
958: gtk_widget_set_sensitive (key_change_widget, 1);
959: }
960:
961: static void did_key_select (GtkObject *o)
962: {
1.1.1.18! root 963: const char *s = gtk_file_selection_get_filename (GTK_FILE_SELECTION (key_selector));
1.1.1.11 root 964:
965: if (quit_gui)
966: return;
967:
968: gtk_widget_set_sensitive (key_change_widget, 1);
969:
970: uae_sem_wait (&gui_sem);
971: gui_keyname = strdup (s);
972: uae_sem_post (&gui_sem);
973: write_comm_pipe_int (&from_gui_pipe, 9, 0);
974: gtk_label_set_text (GTK_LABEL (key_text_widget), gui_keyname);
975: gtk_widget_destroy (key_selector);
976: }
977:
978: static void did_keychange (GtkWidget *w, gpointer data)
979: {
980: gtk_widget_set_sensitive (key_change_widget, 0);
981:
982: key_selector = make_file_selector ("Select a Kickstart key file",
983: did_key_select, did_close_key);
984: filesel_set_path (key_selector, currprefs.path_rom);
1.1.1.10 root 985: }
986:
1.1.1.2 root 987: static void add_empty_vbox (GtkWidget *tobox)
988: {
989: GtkWidget *thing = gtk_vbox_new (FALSE, 0);
990: gtk_widget_show (thing);
991: gtk_box_pack_start (GTK_BOX (tobox), thing, TRUE, TRUE, 0);
992: }
993:
1.1.1.3 root 994: static void add_empty_hbox (GtkWidget *tobox)
995: {
996: GtkWidget *thing = gtk_hbox_new (FALSE, 0);
997: gtk_widget_show (thing);
998: gtk_box_pack_start (GTK_BOX (tobox), thing, TRUE, TRUE, 0);
999: }
1000:
1.1.1.2 root 1001: static void add_centered_to_vbox (GtkWidget *vbox, GtkWidget *w)
1002: {
1003: GtkWidget *hbox = gtk_hbox_new (TRUE, 0);
1004: gtk_widget_show (hbox);
1005: gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, FALSE, 0);
1006: gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
1007: }
1008:
1.1.1.18! root 1009: static GtkWidget *make_labelled_widget (const char *str, GtkWidget *thing, int expand)
1.1.1.2 root 1010: {
1011: GtkWidget *label = gtk_label_new (str);
1012: GtkWidget *hbox2 = gtk_hbox_new (FALSE, 4);
1013:
1014: gtk_widget_show (label);
1015: gtk_widget_show (thing);
1016:
1017: gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, TRUE, 0);
1.1.1.18! root 1018: gtk_box_pack_start (GTK_BOX (hbox2), thing, expand, TRUE, 0);
1.1.1.2 root 1019:
1020: return hbox2;
1021: }
1022:
1.1.1.3 root 1023: static GtkWidget *add_labelled_widget_centered (const char *str, GtkWidget *thing, GtkWidget *vbox)
1.1.1.2 root 1024: {
1.1.1.18! root 1025: GtkWidget *w = make_labelled_widget (str, thing, FALSE);
1.1.1.2 root 1026: gtk_widget_show (w);
1027: add_centered_to_vbox (vbox, w);
1.1.1.3 root 1028: return w;
1.1.1.2 root 1029: }
1030:
1.1.1.10 root 1031: static int make_radio_group (const char **labels, GtkWidget *tobox,
1.1.1.2 root 1032: GtkWidget **saveptr, gint t1, gint t2,
1.1.1.10 root 1033: void (*sigfunc) (void), int count, GSList *group)
1.1.1.2 root 1034: {
1.1.1.10 root 1035: int t = 0;
1036:
1037: while (*labels && (count == -1 || count-- > 0)) {
1038: GtkWidget *thing = gtk_radio_button_new_with_label (group, *labels++);
1039: group = gtk_radio_button_group (GTK_RADIO_BUTTON (thing));
1.1.1.2 root 1040:
1041: *saveptr++ = thing;
1042: gtk_widget_show (thing);
1043: gtk_box_pack_start (GTK_BOX (tobox), thing, t1, t2, 0);
1044: gtk_signal_connect (GTK_OBJECT (thing), "clicked", (GtkSignalFunc) sigfunc, NULL);
1.1.1.10 root 1045: t++;
1.1.1.2 root 1046: }
1.1.1.10 root 1047: return t;
1.1.1.2 root 1048: }
1049:
1050: static GtkWidget *make_radio_group_box (const char *title, const char **labels,
1051: GtkWidget **saveptr, int horiz,
1052: void (*sigfunc) (void))
1053: {
1054: GtkWidget *frame, *newbox;
1055:
1056: frame = gtk_frame_new (title);
1057: newbox = (horiz ? gtk_hbox_new : gtk_vbox_new) (FALSE, 4);
1058: gtk_widget_show (newbox);
1.1.1.4 root 1059: gtk_container_set_border_width (GTK_CONTAINER (newbox), 4);
1.1.1.2 root 1060: gtk_container_add (GTK_CONTAINER (frame), newbox);
1.1.1.10 root 1061: make_radio_group (labels, newbox, saveptr, horiz, !horiz, sigfunc, -1, NULL);
1062: return frame;
1063: }
1064:
1065: static GtkWidget *make_radio_group_box_1 (const char *title, const char **labels,
1066: GtkWidget **saveptr, int horiz,
1067: void (*sigfunc) (void), int elts_per_column)
1068: {
1069: GtkWidget *frame, *newbox;
1070: GtkWidget *column;
1071: GSList *group = 0;
1072:
1073: frame = gtk_frame_new (title);
1074: column = (horiz ? gtk_vbox_new : gtk_hbox_new) (FALSE, 4);
1075: gtk_container_add (GTK_CONTAINER (frame), column);
1076: gtk_widget_show (column);
1077:
1078: while (*labels) {
1079: int count;
1080: newbox = (horiz ? gtk_hbox_new : gtk_vbox_new) (FALSE, 4);
1081: gtk_widget_show (newbox);
1082: gtk_container_set_border_width (GTK_CONTAINER (newbox), 4);
1083: gtk_container_add (GTK_CONTAINER (column), newbox);
1084: count = make_radio_group (labels, newbox, saveptr, horiz, !horiz, sigfunc, elts_per_column, group);
1085: labels += count;
1086: saveptr += count;
1087: group = gtk_radio_button_group (GTK_RADIO_BUTTON (saveptr[-1]));
1088: }
1.1.1.2 root 1089: return frame;
1090: }
1091:
1.1 root 1092: static GtkWidget *make_led (int nr)
1093: {
1094: GtkWidget *subframe, *the_led, *thing;
1095: GdkColormap *colormap;
1096:
1097: the_led = gtk_vbox_new (FALSE, 0);
1098: gtk_widget_show (the_led);
1099:
1100: thing = gtk_preview_new (GTK_PREVIEW_COLOR);
1101: gtk_box_pack_start (GTK_BOX (the_led), thing, TRUE, TRUE, 0);
1102: gtk_widget_show (thing);
1103:
1104: subframe = gtk_frame_new (NULL);
1105: gtk_box_pack_start (GTK_BOX (the_led), subframe, TRUE, TRUE, 0);
1106: gtk_widget_show (subframe);
1107:
1108: thing = gtk_drawing_area_new ();
1109: gtk_drawing_area_size (GTK_DRAWING_AREA (thing), 20, 5);
1110: gtk_widget_set_events (thing, GDK_EXPOSURE_MASK);
1111: gtk_container_add (GTK_CONTAINER (subframe), thing);
1112: colormap = gtk_widget_get_colormap (thing);
1113: led_on[nr].red = nr == 0 ? 0xEEEE : 0xCCCC;
1114: led_on[nr].green = nr == 0 ? 0: 0xFFFF;
1115: led_on[nr].blue = 0;
1116: led_on[nr].pixel = 0;
1117: led_off[nr].red = 0;
1118: led_off[nr].green = 0;
1119: led_off[nr].blue = 0;
1120: led_off[nr].pixel = 0;
1121: gdk_color_alloc (colormap, led_on + nr);
1122: gdk_color_alloc (colormap, led_off + nr);
1123: led_widgets[nr] = thing;
1124: gtk_signal_connect (GTK_OBJECT (thing), "event",
1125: (GtkSignalFunc) driveled_event, (gpointer) thing);
1126: gtk_widget_show (thing);
1127:
1128: thing = gtk_preview_new (GTK_PREVIEW_COLOR);
1129: gtk_box_pack_start (GTK_BOX (the_led), thing, TRUE, TRUE, 0);
1130: gtk_widget_show (thing);
1.1.1.15 root 1131:
1.1 root 1132: return the_led;
1133: }
1134:
1.1.1.11 root 1135: static GtkWidget *make_file_container (const char *title, GtkWidget *vbox)
1136: {
1137: GtkWidget *thing = gtk_frame_new (title);
1138: GtkWidget *buttonbox = gtk_hbox_new (FALSE, 4);
1139:
1140: gtk_container_set_border_width (GTK_CONTAINER (buttonbox), 4);
1141: gtk_container_add (GTK_CONTAINER (thing), buttonbox);
1142: gtk_box_pack_start (GTK_BOX (vbox), thing, FALSE, TRUE, 0);
1143: gtk_widget_show (buttonbox);
1144: gtk_widget_show (thing);
1145:
1146: return buttonbox;
1147: }
1148:
1149: static GtkWidget *make_file_widget (GtkWidget *buttonbox)
1150: {
1151: GtkWidget *thing, *subthing;
1152: GtkWidget *subframe = gtk_frame_new (NULL);
1153:
1154: gtk_frame_set_shadow_type (GTK_FRAME (subframe), GTK_SHADOW_ETCHED_OUT);
1155: gtk_box_pack_start (GTK_BOX (buttonbox), subframe, TRUE, TRUE, 0);
1156: gtk_widget_show (subframe);
1157: subthing = gtk_vbox_new (FALSE, 0);
1158: gtk_widget_show (subthing);
1159: gtk_container_add (GTK_CONTAINER (subframe), subthing);
1160: thing = gtk_label_new ("");
1161: gtk_widget_show (thing);
1162: gtk_box_pack_start (GTK_BOX (subthing), thing, TRUE, TRUE, 0);
1163:
1164: return thing;
1165: }
1166:
1.1 root 1167: static void make_floppy_disks (GtkWidget *vbox)
1168: {
1.1.1.2 root 1169: GtkWidget *thing, *subthing, *subframe, *buttonbox;
1170: char buf[5];
1.1 root 1171: int i;
1.1.1.2 root 1172:
1173: add_empty_vbox (vbox);
1174:
1.1 root 1175: for (i = 0; i < 4; i++) {
1.1.1.2 root 1176: /* Frame with an hbox and the "DFx:" title */
1.1 root 1177: sprintf (buf, "DF%d:", i);
1.1.1.11 root 1178: buttonbox = make_file_container (buf, vbox);
1.1.1.18! root 1179:
1.1.1.2 root 1180: /* LED */
1.1 root 1181: subthing = make_led (i + 1);
1182: gtk_box_pack_start (GTK_BOX (buttonbox), subthing, FALSE, TRUE, 0);
1183:
1.1.1.2 root 1184: /* Current file display */
1.1.1.11 root 1185: disk_text_widget[i] = make_file_widget (buttonbox);
1.1 root 1186:
1187: /* Now, the buttons. */
1188: thing = gtk_button_new_with_label ("Eject");
1189: gtk_box_pack_start (GTK_BOX (buttonbox), thing, FALSE, TRUE, 0);
1190: gtk_widget_show (thing);
1191: disk_eject_widget[i] = thing;
1.1.1.2 root 1192: gtk_signal_connect (GTK_OBJECT (thing), "clicked", (GtkSignalFunc) did_eject, (gpointer) i);
1.1 root 1193:
1194: thing = gtk_button_new_with_label ("Insert");
1195: gtk_box_pack_start (GTK_BOX (buttonbox), thing, FALSE, TRUE, 0);
1196: gtk_widget_show (thing);
1197: disk_insert_widget[i] = thing;
1.1.1.2 root 1198: gtk_signal_connect (GTK_OBJECT (thing), "clicked", (GtkSignalFunc) did_insert, (gpointer) i);
1.1 root 1199: }
1.1.1.2 root 1200:
1201: add_empty_vbox (vbox);
1.1 root 1202: }
1203:
1.1.1.3 root 1204: static GtkWidget *make_cpu_speed_sel (void)
1205: {
1.1.1.10 root 1206: int t;
1.1.1.3 root 1207: static const char *labels[] = {
1208: "Optimize for host CPU speed","Approximate 68000/7MHz speed", "Adjustable",
1209: NULL
1210: };
1211: GtkWidget *frame, *newbox;
1212:
1213: frame = gtk_frame_new ("CPU speed");
1214: newbox = gtk_vbox_new (FALSE, 4);
1215: gtk_widget_show (newbox);
1.1.1.4 root 1216: gtk_container_set_border_width (GTK_CONTAINER (newbox), 4);
1.1.1.3 root 1217: gtk_container_add (GTK_CONTAINER (frame), newbox);
1.1.1.10 root 1218: make_radio_group (labels, newbox, cpuspeed_widgets, 0, 1, cpuspeed_changed, -1, NULL);
1.1.1.3 root 1219:
1.1.1.10 root 1220: t = currprefs.m68k_speed > 0 ? currprefs.m68k_speed : 4 * CYCLE_UNIT;
1221: cpuspeed_adj = GTK_ADJUSTMENT (gtk_adjustment_new (t, 1.0, 5120.0, 1.0, 1.0, 1.0));
1.1.1.3 root 1222: gtk_signal_connect (GTK_OBJECT (cpuspeed_adj), "value_changed",
1223: GTK_SIGNAL_FUNC (cpuspeed_changed), NULL);
1224:
1225: cpuspeed_scale = gtk_hscale_new (cpuspeed_adj);
1226: gtk_range_set_update_policy (GTK_RANGE (cpuspeed_scale), GTK_UPDATE_DELAYED);
1227: gtk_scale_set_digits (GTK_SCALE (cpuspeed_scale), 0);
1228: gtk_scale_set_value_pos (GTK_SCALE (cpuspeed_scale), GTK_POS_RIGHT);
1.1.1.18! root 1229: cpuspeed_scale = make_labelled_widget ("Cycles/insn:", cpuspeed_scale, TRUE);
! 1230: gtk_widget_show (cpuspeed_scale);
! 1231: gtk_box_pack_start (GTK_BOX (newbox), cpuspeed_scale, FALSE, FALSE, 0);
1.1.1.3 root 1232:
1233: return frame;
1234: }
1235:
1.1.1.2 root 1236: static void make_cpu_widgets (GtkWidget *vbox)
1.1 root 1237: {
1238: int i;
1.1.1.3 root 1239: GtkWidget *newbox, *hbox, *frame;
1.1.1.18! root 1240: GtkWidget *thing, *label;
1.1.1.2 root 1241: static const char *radiolabels[] = {
1.1.1.18! root 1242: "68000", "68010", "68020", "68020+68881", "68EC020", "68EC020+68881", "68040",
1.1.1.2 root 1243: NULL
1244: };
1245:
1246: add_empty_vbox (vbox);
1247:
1.1.1.3 root 1248: hbox = gtk_hbox_new (FALSE, 0);
1249: add_empty_vbox (hbox);
1250:
1251: newbox = make_radio_group_box ("CPU type", radiolabels, cpu_widget, 0, cputype_changed);
1.1.1.2 root 1252: gtk_widget_show (newbox);
1.1.1.3 root 1253: gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, FALSE, 0);
1254:
1255: newbox = make_cpu_speed_sel ();
1256: gtk_widget_show (newbox);
1257: gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, FALSE, 0);
1258:
1259: add_empty_vbox (hbox);
1.1.1.18! root 1260: gtk_widget_show (hbox);
1.1.1.3 root 1261: gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
1.1 root 1262:
1.1.1.18! root 1263: #if 0
1.1 root 1264: frame = gtk_frame_new ("CPU flags");
1.1.1.2 root 1265: add_centered_to_vbox (vbox, frame);
1.1 root 1266: gtk_widget_show (frame);
1.1.1.2 root 1267: newbox = gtk_vbox_new (FALSE, 4);
1268: gtk_widget_show (newbox);
1.1.1.4 root 1269: gtk_container_set_border_width (GTK_CONTAINER (newbox), 4);
1.1.1.2 root 1270: gtk_container_add (GTK_CONTAINER (frame), newbox);
1.1 root 1271:
1272: a24m_widget = gtk_check_button_new_with_label ("24 bit address space");
1.1.1.2 root 1273: add_centered_to_vbox (newbox, a24m_widget);
1.1.1.18! root 1274: gtk_widget_show (a24m_widget);
1.1 root 1275: ccpu_widget = gtk_check_button_new_with_label ("Slow but compatible");
1.1.1.2 root 1276: add_centered_to_vbox (newbox, ccpu_widget);
1.1 root 1277: gtk_widget_show (ccpu_widget);
1.1.1.8 root 1278:
1.1 root 1279: gtk_signal_connect (GTK_OBJECT (ccpu_widget), "clicked",
1280: (GtkSignalFunc) cputype_changed, NULL);
1281: gtk_signal_connect (GTK_OBJECT (a24m_widget), "clicked",
1.1.1.18! root 1282: (GtkSignalFunc) cputype_changed, NULL);
! 1283: #endif
! 1284:
! 1285: label = gtk_label_new ("CPU type settings take effect after the next reset.");
! 1286: gtk_widget_show (label);
! 1287: add_centered_to_vbox (vbox, label);
! 1288:
! 1289: add_empty_vbox (vbox);
1.1 root 1290: }
1291:
1.1.1.2 root 1292: static void make_gfx_widgets (GtkWidget *vbox)
1.1 root 1293: {
1.1.1.10 root 1294: GtkWidget *thing, *frame, *newbox, *hbox;
1.1 root 1295:
1.1.1.2 root 1296: add_empty_vbox (vbox);
1.1 root 1297:
1.1.1.10 root 1298: hbox = gtk_hbox_new (FALSE, 10);
1299: gtk_widget_show (hbox);
1300: add_centered_to_vbox (vbox, hbox);
1301:
1302: frame = gtk_frame_new ("Miscellaneous");
1303: gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
1304:
1305: gtk_widget_show (frame);
1306: newbox = gtk_vbox_new (FALSE, 4);
1307: gtk_widget_show (newbox);
1308: gtk_container_set_border_width (GTK_CONTAINER (newbox), 4);
1309: gtk_container_add (GTK_CONTAINER (frame), newbox);
1310:
1.1.1.18! root 1311: framerate_adj = GTK_ADJUSTMENT (gtk_adjustment_new (currprefs.gfx_framerate, 1, 21, 1, 1, 1));
1.1 root 1312: gtk_signal_connect (GTK_OBJECT (framerate_adj), "value_changed",
1.1.1.2 root 1313: GTK_SIGNAL_FUNC (custom_changed), NULL);
1.1 root 1314:
1315: thing = gtk_hscale_new (framerate_adj);
1316: gtk_range_set_update_policy (GTK_RANGE (thing), GTK_UPDATE_DELAYED);
1317: gtk_scale_set_digits (GTK_SCALE (thing), 0);
1318: gtk_scale_set_value_pos (GTK_SCALE (thing), GTK_POS_RIGHT);
1.1.1.18! root 1319: thing = make_labelled_widget ("Framerate:", thing, TRUE);
! 1320: gtk_widget_show (thing);
! 1321: gtk_box_pack_start (GTK_BOX (newbox), thing, FALSE, FALSE, 0);
1.1 root 1322:
1323: b32_widget = gtk_check_button_new_with_label ("32 bit blitter");
1.1.1.10 root 1324: add_centered_to_vbox (newbox, b32_widget);
1.1.1.7 root 1325: #if 0
1.1 root 1326: gtk_widget_show (b32_widget);
1.1.1.7 root 1327: #endif
1.1 root 1328: bimm_widget = gtk_check_button_new_with_label ("Immediate blits");
1.1.1.18! root 1329: gtk_box_pack_start (GTK_BOX (newbox), bimm_widget, FALSE, FALSE, 0);
1.1 root 1330: gtk_widget_show (bimm_widget);
1331:
1.1.1.18! root 1332: showleds_widget = gtk_check_button_new_with_label ("Show LEDs in Amiga display");
! 1333: gtk_box_pack_start (GTK_BOX (newbox), showleds_widget, FALSE, FALSE, 0);
! 1334: gtk_widget_show (showleds_widget);
! 1335:
1.1.1.7 root 1336: afscr_widget = gtk_check_button_new_with_label ("Amiga modes fullscreen");
1.1.1.10 root 1337: add_centered_to_vbox (newbox, afscr_widget);
1.1.1.7 root 1338: #if 0
1339: gtk_widget_show (afscr_widget);
1340: #endif
1341: pfscr_widget = gtk_check_button_new_with_label ("Picasso modes fullscreen");
1.1.1.10 root 1342: add_centered_to_vbox (newbox, pfscr_widget);
1.1.1.7 root 1343: #if 0
1344: gtk_widget_show (pfscr_widget);
1345: #endif
1.1.1.2 root 1346: add_empty_vbox (vbox);
1347:
1.1 root 1348: gtk_signal_connect (GTK_OBJECT (bimm_widget), "clicked",
1.1.1.2 root 1349: (GtkSignalFunc) custom_changed, NULL);
1.1.1.18! root 1350: gtk_signal_connect (GTK_OBJECT (showleds_widget), "clicked",
! 1351: (GtkSignalFunc) custom_changed, NULL);
1.1.1.10 root 1352: #if 0
1.1 root 1353: gtk_signal_connect (GTK_OBJECT (b32_widget), "clicked",
1.1.1.2 root 1354: (GtkSignalFunc) custom_changed, NULL);
1.1.1.7 root 1355: gtk_signal_connect (GTK_OBJECT (afscr_widget), "clicked",
1356: (GtkSignalFunc) custom_changed, NULL);
1357: gtk_signal_connect (GTK_OBJECT (pfscr_widget), "clicked",
1358: (GtkSignalFunc) custom_changed, NULL);
1.1.1.10 root 1359: #endif
1360: }
1361:
1362: static void make_chipset_widgets (GtkWidget *vbox)
1363: {
1364: GtkWidget *frame, *newbox, *hbox;
1365: static const char *colllabels[] = {
1366: "None (fastest)", "Sprites only", "Sprites & playfields", "Full (very slow)",
1367: NULL
1368: };
1369: static const char *cslevellabels[] = {
1370: "OCS", "ECS Agnus", "Full ECS", "AGA", NULL
1371: };
1372:
1373: add_empty_vbox (vbox);
1374:
1375: hbox = gtk_hbox_new (FALSE, 10);
1376: gtk_widget_show (hbox);
1377: add_centered_to_vbox (vbox, hbox);
1378:
1379: newbox = make_radio_group_box ("Sprite collisions", colllabels, coll_widget, 0, coll_changed);
1380: gtk_widget_show (newbox);
1381: gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, TRUE, 0);
1382:
1383: newbox = make_radio_group_box ("Chipset", cslevellabels, cslevel_widget, 0, cslevel_changed);
1384: gtk_widget_show (newbox);
1385: gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, TRUE, 0);
1386:
1387: add_empty_vbox (vbox);
1.1.1.2 root 1388: }
1389:
1390: static void make_sound_widgets (GtkWidget *vbox)
1391: {
1392: GtkWidget *frame, *newbox;
1393: int i;
1394: GtkWidget *hbox;
1395: static const char *soundlabels1[] = {
1396: "None", "No output", "Normal", "Accurate",
1397: NULL
1398: }, *soundlabels2[] = {
1399: "8 bit", "16 bit",
1400: NULL
1401: }, *soundlabels3[] = {
1.1.1.9 root 1402: "Mono", "Stereo", "Mixed",
1.1.1.2 root 1403: NULL
1404: };
1405:
1406: add_empty_vbox (vbox);
1407:
1408: newbox = make_radio_group_box ("Mode", soundlabels1, sound_widget, 1, sound_changed);
1409: gtk_widget_show (newbox);
1410: add_centered_to_vbox (vbox, newbox);
1411:
1412: hbox = gtk_hbox_new (FALSE, 10);
1413: gtk_widget_show (hbox);
1414: add_centered_to_vbox (vbox, hbox);
1415: newbox = make_radio_group_box ("Channels", soundlabels3, sound_ch_widget, 1, sound_changed);
1416: gtk_widget_show (newbox);
1417: gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, TRUE, 0);
1418: newbox = make_radio_group_box ("Resolution", soundlabels2, sound_bits_widget, 1, sound_changed);
1419: gtk_widget_show (newbox);
1420: gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, TRUE, 0);
1.1.1.3 root 1421:
1.1.1.2 root 1422: add_empty_vbox (vbox);
1.1 root 1423: }
1424:
1.1.1.10 root 1425: static void make_mem_widgets (GtkWidget *vbox)
1426: {
1427: GtkWidget *hbox = gtk_hbox_new (FALSE, 10);
1428: GtkWidget *label, *frame;
1429:
1430: static const char *chiplabels[] = {
1431: "512 KB", "1 MB", "2 MB", "4 MB", "8 MB", NULL
1432: };
1433: static const char *bogolabels[] = {
1434: "None", "512 KB", "1 MB", "1.8 MB", NULL
1435: };
1436: static const char *fastlabels[] = {
1437: "None", "1 MB", "2 MB", "4 MB", "8 MB", NULL
1438: };
1439: static const char *z3labels[] = {
1440: "None", "1 MB", "2 MB", "4 MB", "8 MB",
1441: "16 MB", "32 MB", "64 MB", "128 MB", "256 MB",
1442: NULL
1443: };
1.1.1.18! root 1444: static const char *p96labels[] = {
! 1445: "None", "1 MB", "2 MB", "4 MB", "8 MB", "16 MB", "32 MB", NULL
! 1446: };
1.1.1.10 root 1447:
1448: add_empty_vbox (vbox);
1.1.1.11 root 1449:
1450: {
1451: GtkWidget *buttonbox = make_file_container ("Kickstart ROM file:", vbox);
1452: GtkWidget *thing = gtk_button_new_with_label ("Change");
1453:
1454: /* Current file display */
1455: rom_text_widget = make_file_widget (buttonbox);
1456:
1457: gtk_box_pack_start (GTK_BOX (buttonbox), thing, FALSE, TRUE, 0);
1458: gtk_widget_show (thing);
1459: rom_change_widget = thing;
1460: gtk_signal_connect (GTK_OBJECT (thing), "clicked", (GtkSignalFunc) did_romchange, 0);
1461: }
1462:
1463: {
1464: GtkWidget *buttonbox = make_file_container ("ROM key file for Cloanto Amiga Forever:", vbox);
1465: GtkWidget *thing = gtk_button_new_with_label ("Change");
1466:
1467: /* Current file display */
1468: key_text_widget = make_file_widget (buttonbox);
1469:
1470: gtk_box_pack_start (GTK_BOX (buttonbox), thing, FALSE, TRUE, 0);
1471: gtk_widget_show (thing);
1472: key_change_widget = thing;
1473: gtk_signal_connect (GTK_OBJECT (thing), "clicked", (GtkSignalFunc) did_keychange, 0);
1474: }
1475:
1.1.1.10 root 1476: gtk_widget_show (hbox);
1477: add_centered_to_vbox (vbox, hbox);
1478:
1479: add_empty_vbox (vbox);
1480:
1481: label = gtk_label_new ("These settings take effect after the next reset.");
1482: gtk_widget_show (label);
1483: add_centered_to_vbox (vbox, label);
1484:
1485: frame = make_radio_group_box ("Chip Mem", chiplabels, chipsize_widget, 0, chipsize_changed);
1486: gtk_widget_show (frame);
1487: gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
1488:
1489: frame = make_radio_group_box ("Slow Mem", bogolabels, bogosize_widget, 0, bogosize_changed);
1490: gtk_widget_show (frame);
1491: gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
1492:
1493: frame = make_radio_group_box ("Fast Mem", fastlabels, fastsize_widget, 0, fastsize_changed);
1494: gtk_widget_show (frame);
1495: gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
1496:
1497: frame = make_radio_group_box_1 ("Z3 Mem", z3labels, z3size_widget, 0, z3size_changed, 5);
1498: gtk_widget_show (frame);
1499: gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
1.1.1.18! root 1500:
! 1501: frame = make_radio_group_box_1 ("P96 RAM", p96labels, p96size_widget, 0, p96size_changed, 4);
! 1502: gtk_widget_show (frame);
! 1503: gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
1.1.1.10 root 1504: }
1505:
1.1.1.2 root 1506: static void make_joy_widgets (GtkWidget *dvbox)
1.1 root 1507: {
1508: int i;
1.1.1.2 root 1509: GtkWidget *hbox = gtk_hbox_new (FALSE, 10);
1510: static const char *joylabels[] = {
1511: "Joystick 0", "Joystick 1", "Mouse", "Numeric pad",
1512: "Cursor keys/Right Ctrl", "T/F/H/B/Left Alt",
1513: NULL
1514: };
1515:
1516: add_empty_vbox (dvbox);
1517: gtk_widget_show (hbox);
1518: add_centered_to_vbox (dvbox, hbox);
1.1 root 1519:
1.1.1.18! root 1520: legacy_widget = gtk_check_button_new_with_label ("Use legacy configuration");
! 1521: add_centered_to_vbox (dvbox, legacy_widget);
! 1522: gtk_widget_show (legacy_widget);
! 1523: gtk_signal_connect (GTK_OBJECT (legacy_widget), "clicked",
! 1524: (GtkSignalFunc) joy_changed, NULL);
! 1525:
1.1 root 1526: for (i = 0; i < 2; i++) {
1527: GtkWidget *vbox, *frame;
1528: GtkWidget *thing;
1529: char buffer[20];
1530: int j;
1531:
1532: sprintf (buffer, "Port %d", i);
1.1.1.2 root 1533: frame = make_radio_group_box (buffer, joylabels, joy_widget[i], 0, joy_changed);
1.1 root 1534: gtk_widget_show (frame);
1.1.1.2 root 1535: gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, TRUE, 0);
1.1 root 1536: }
1.1.1.2 root 1537:
1538: add_empty_vbox (dvbox);
1539: }
1540:
1.1.1.12 root 1541: static int hd_change_mode;
1542:
1.1.1.11 root 1543: static void newdir_ok (void)
1544: {
1545: int n;
1546: strcpy (dirdlg_volname, gtk_entry_get_text (GTK_ENTRY (volname_entry)));
1547: strcpy (dirdlg_path, gtk_entry_get_text (GTK_ENTRY (path_entry)));
1548:
1549: n = strlen (dirdlg_volname);
1550: /* Strip colons from the end. */
1551: if (n > 0) {
1552: if (dirdlg_volname[n - 1] == ':')
1553: dirdlg_volname[n - 1] = '\0';
1554: }
1555: if (strlen (dirdlg_volname) == 0 || strlen (dirdlg_path) == 0) {
1556: /* Uh, no messageboxes in gtk? */
1.1.1.12 root 1557: } else if (hd_change_mode) {
1558: set_filesys_unit (currprefs.mountinfo, selected_hd_row, dirdlg_volname, dirdlg_path,
1559: 0, 0, 0, 0, 0);
1560: set_hd_state ();
1.1.1.11 root 1561: } else {
1562: add_filesys_unit (currprefs.mountinfo, dirdlg_volname, dirdlg_path,
1563: 0, 0, 0, 0, 0);
1564: set_hd_state ();
1565: }
1566: gtk_widget_destroy (dirdlg);
1567: }
1568:
1569: static GtkWidget *create_dirdlg (const char *title)
1570: {
1571: GtkWidget *vbox, *hbox, *thing, *label1, *button;
1572:
1573: dirdlg = gtk_dialog_new ();
1574:
1575: gtk_window_set_title (GTK_WINDOW (dirdlg), title);
1576: gtk_window_set_position (GTK_WINDOW (dirdlg), GTK_WIN_POS_MOUSE);
1577: gtk_window_set_modal (GTK_WINDOW (dirdlg), TRUE);
1578: gtk_widget_show (dirdlg);
1579:
1580: vbox = GTK_DIALOG (dirdlg)->vbox;
1581: hbox = gtk_hbox_new (FALSE, 10);
1582: gtk_widget_show (hbox);
1583: gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 10);
1584: label1 = gtk_label_new ("Path:");
1585: gtk_box_pack_start (GTK_BOX (hbox), label1, FALSE, TRUE, 10);
1586: gtk_widget_show (label1);
1587: thing = gtk_entry_new_with_max_length (255);
1.1.1.18! root 1588: gtk_box_pack_start (GTK_BOX (hbox), thing, TRUE, TRUE, 10);
1.1.1.11 root 1589: gtk_widget_show (thing);
1590: path_entry = thing;
1591:
1592: hbox = gtk_hbox_new (FALSE, 10);
1593: gtk_widget_show (hbox);
1594: gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 10);
1595: thing = gtk_label_new ("Volume name:");
1596: gtk_box_pack_start (GTK_BOX (hbox), thing, FALSE, TRUE, 10);
1597: gtk_widget_show (thing);
1598: thing = gtk_entry_new_with_max_length (255);
1.1.1.18! root 1599: gtk_box_pack_start (GTK_BOX (hbox), thing, TRUE, TRUE, 10);
1.1.1.11 root 1600: gtk_widget_show (thing);
1601: gtk_widget_set_usize (thing, 200, -1);
1602: volname_entry = thing;
1603:
1604: hbox = GTK_DIALOG (dirdlg)->action_area;
1605: button = gtk_button_new_with_label ("OK");
1606: gtk_signal_connect (GTK_OBJECT (button), "clicked",
1607: GTK_SIGNAL_FUNC(newdir_ok), NULL);
1608: GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
1609: gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
1610: gtk_widget_grab_default (button);
1.1.1.12 root 1611: gtk_widget_show (button);
1.1.1.11 root 1612:
1613: button = gtk_button_new_with_label ("Cancel");
1614: gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
1615: GTK_SIGNAL_FUNC (gtk_widget_destroy),
1616: GTK_OBJECT (dirdlg));
1617: gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
1618: gtk_widget_show (button);
1.1.1.14 root 1619: return 0;
1.1.1.11 root 1620: }
1621:
1622: static void did_newdir (void)
1623: {
1.1.1.12 root 1624: hd_change_mode = 0;
1.1.1.11 root 1625: create_dirdlg ("Add a new mounted directory");
1626: }
1627: static void did_newhdf (void)
1628: {
1.1.1.12 root 1629: hd_change_mode = 0;
1.1.1.11 root 1630: }
1631:
1632: static void did_hdchange (void)
1633: {
1634: int secspertrack, surfaces, reserved, blocksize, size;
1635: int cylinders, readonly;
1636: char *volname, *rootdir;
1637: char *failure;
1638:
1639: failure = get_filesys_unit (currprefs.mountinfo, selected_hd_row,
1640: &volname, &rootdir, &readonly,
1641: &secspertrack, &surfaces, &reserved,
1642: &cylinders, &size, &blocksize);
1643:
1.1.1.12 root 1644: hd_change_mode = 1;
1.1.1.11 root 1645: if (is_hardfile (currprefs.mountinfo, selected_hd_row)) {
1646: } else {
1.1.1.18! root 1647: create_dirdlg ("Change a mounted directory");
1.1.1.11 root 1648: gtk_entry_set_text (GTK_ENTRY (volname_entry), volname);
1649: gtk_entry_set_text (GTK_ENTRY (path_entry), rootdir);
1650: }
1651: }
1652: static void did_hddel (void)
1653: {
1654: kill_filesys_unit (currprefs.mountinfo, selected_hd_row);
1655: set_hd_state ();
1656: }
1657:
1658: static void hdselect (GtkWidget *widget, gint row, gint column, GdkEventButton *bevent,
1659: gpointer user_data)
1660: {
1661: selected_hd_row = row;
1662: gtk_widget_set_sensitive (hdchange_button, TRUE);
1663: gtk_widget_set_sensitive (hddel_button, TRUE);
1664: }
1665:
1666: static void hdunselect (GtkWidget *widget, gint row, gint column, GdkEventButton *bevent,
1667: gpointer user_data)
1668: {
1669: gtk_widget_set_sensitive (hdchange_button, FALSE);
1670: gtk_widget_set_sensitive (hddel_button, FALSE);
1671: }
1672:
1673:
1.1.1.6 root 1674: static GtkWidget *make_buttons (const char *label, GtkWidget *box, void (*sigfunc) (void), GtkWidget *(*create)(const char *label))
1.1.1.2 root 1675: {
1.1.1.6 root 1676: GtkWidget *thing = create (label);
1.1.1.2 root 1677: gtk_widget_show (thing);
1678: gtk_signal_connect (GTK_OBJECT (thing), "clicked", (GtkSignalFunc) sigfunc, NULL);
1679: gtk_box_pack_start (GTK_BOX (box), thing, TRUE, TRUE, 0);
1.1.1.6 root 1680:
1681: return thing;
1.1 root 1682: }
1.1.1.6 root 1683: #define make_button(label, box, sigfunc) make_buttons(label, box, sigfunc, gtk_button_new_with_label)
1.1 root 1684:
1.1.1.11 root 1685: static void make_hd_widgets (GtkWidget *dvbox)
1686: {
1687: GtkWidget *thing, *buttonbox, *hbox;
1688: char *titles [] = {
1689: "Volume", "File/Directory", "R/O", "Heads", "Cyl.", "Sec.", "Rsrvd", "Size", "Blksize"
1690: };
1691:
1692: thing = gtk_clist_new_with_titles (9, titles);
1693: gtk_clist_set_selection_mode (GTK_CLIST (thing), GTK_SELECTION_SINGLE);
1694: gtk_signal_connect (GTK_OBJECT (thing), "select_row", (GtkSignalFunc) hdselect, NULL);
1695: gtk_signal_connect (GTK_OBJECT (thing), "unselect_row", (GtkSignalFunc) hdunselect, NULL);
1.1.1.14 root 1696: gtk_clist_set_column_auto_resize (GTK_CLIST (thing), 0, TRUE);
1697: gtk_clist_set_column_auto_resize (GTK_CLIST (thing), 1, TRUE);
1.1.1.11 root 1698: gtk_widget_set_usize (thing, -1, 200);
1.1.1.14 root 1699: hdlist_widget = thing;
1.1.1.11 root 1700:
1701: gtk_widget_show (thing);
1702: add_centered_to_vbox (dvbox, thing);
1703:
1704: hbox = gtk_hbox_new (FALSE, 10);
1705: gtk_widget_show (hbox);
1706: gtk_box_pack_start (GTK_BOX (dvbox), hbox, FALSE, TRUE, 0);
1707:
1708: /* The buttons */
1709: buttonbox = gtk_hbox_new (TRUE, 4);
1710: gtk_widget_show (buttonbox);
1711: gtk_box_pack_start (GTK_BOX (hbox), buttonbox, TRUE, TRUE, 0);
1712: make_button ("New filesystem...", buttonbox, did_newdir);
1713: #if 0 /* later... */
1714: make_button ("New hardfile...", buttonbox, did_newhdf);
1715: #endif
1716: hdchange_button = make_button ("Change...", buttonbox, did_hdchange);
1717: hddel_button = make_button ("Delete", buttonbox, did_hddel);
1718:
1719: thing = gtk_label_new ("These settings take effect after the next reset.");
1720: gtk_widget_show (thing);
1721: add_centered_to_vbox (dvbox, thing);
1722: }
1723:
1724: static void make_about_widgets (GtkWidget *dvbox)
1725: {
1.1.1.14 root 1726: GtkWidget *lab_version;
1.1.1.11 root 1727: GtkStyle *style;
1728: GdkFont *font;
1729: char t[20];
1730:
1731: add_empty_vbox (dvbox);
1732:
1733: sprintf (t, "UAE %d.%d.%d", UAEMAJOR, UAEMINOR, UAESUBREV);
1.1.1.14 root 1734: lab_version = gtk_label_new (t);
1735: lab_info = gtk_label_new ("Choose your settings, then deselect the Pause button to start!");
1.1.1.11 root 1736:
1.1.1.18! root 1737: style = gtk_style_copy (GTK_WIDGET (lab_version)->style);
! 1738: pango_font_description_free (style->font_desc);
! 1739: style->font_desc = pango_font_description_from_string ("Sans 24");
! 1740: gtk_widget_set_style (lab_version, style);
1.1.1.14 root 1741:
1742: add_centered_to_vbox (dvbox, lab_version);
1743: add_centered_to_vbox (dvbox, lab_info);
1744: gtk_widget_show (lab_version);
1745: if (currprefs.start_gui == 1)
1746: gtk_widget_show (lab_info);
1.1.1.11 root 1747:
1748: add_empty_vbox (dvbox);
1749: }
1750:
1751: static void create_guidlg (void)
1.1 root 1752: {
1.1.1.15 root 1753: GtkWidget *window;
1.1.1.2 root 1754: GtkWidget *buttonbox, *vbox, *hbox;
1.1 root 1755: GtkWidget *thing;
1.1.1.14 root 1756: unsigned int i;
1.1 root 1757: int argc = 1;
1758: char *a[] = {"UAE"};
1759: char **argv = a;
1.1.1.2 root 1760: static const struct _pages {
1761: const char *title;
1762: void (*createfunc)(GtkWidget *);
1763: } pages[] = {
1.1.1.10 root 1764: /* ??? If this isn't the first page, there are errors in draw_led. */
1.1.1.2 root 1765: { "Floppy disks", make_floppy_disks },
1.1.1.10 root 1766: { "Memory", make_mem_widgets },
1.1.1.2 root 1767: { "CPU emulation", make_cpu_widgets },
1768: { "Graphics", make_gfx_widgets },
1.1.1.10 root 1769: { "Chipset", make_chipset_widgets },
1.1.1.2 root 1770: { "Sound", make_sound_widgets },
1.1.1.11 root 1771: { "Game ports", make_joy_widgets },
1772: { "Harddisks", make_hd_widgets },
1773: { "About", make_about_widgets }
1.1.1.2 root 1774: };
1.1 root 1775:
1776: gtk_init (&argc, &argv);
1777: gtk_rc_parse ("uaegtkrc");
1778:
1.1.1.11 root 1779: gui_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1780: gtk_window_set_title (GTK_WINDOW (gui_window), "UAE control");
1.1 root 1781:
1782: vbox = gtk_vbox_new (FALSE, 4);
1.1.1.11 root 1783: gtk_container_add (GTK_CONTAINER (gui_window), vbox);
1784: gtk_container_set_border_width (GTK_CONTAINER (gui_window), 10);
1.1 root 1785:
1.1.1.2 root 1786: /* First line - buttons and power LED */
1787: hbox = gtk_hbox_new (FALSE, 10);
1788: gtk_widget_show (hbox);
1789: gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
1.1 root 1790:
1.1.1.2 root 1791: /* The buttons */
1792: buttonbox = gtk_hbox_new (TRUE, 4);
1.1 root 1793: gtk_widget_show (buttonbox);
1.1.1.2 root 1794: gtk_box_pack_start (GTK_BOX (hbox), buttonbox, TRUE, TRUE, 0);
1795: make_button ("Reset", buttonbox, did_reset);
1796: make_button ("Debug", buttonbox, did_debug);
1797: make_button ("Quit", buttonbox, did_quit);
1798: make_button ("Save config", buttonbox, save_config);
1.1.1.6 root 1799: pause_uae_widget = make_buttons ("Pause", buttonbox, pause_uae, gtk_toggle_button_new_with_label);
1.1 root 1800:
1.1.1.2 root 1801: /* The LED */
1802: thing = make_led (0);
1.1.1.18! root 1803: thing = make_labelled_widget ("Power:", thing, FALSE);
1.1 root 1804: gtk_widget_show (thing);
1.1.1.2 root 1805: gtk_box_pack_start (GTK_BOX (hbox), thing, FALSE, TRUE, 0);
1.1 root 1806:
1.1.1.10 root 1807: /* More buttons */
1808: buttonbox = gtk_hbox_new (TRUE, 4);
1809: gtk_widget_show (buttonbox);
1810: gtk_box_pack_start (GTK_BOX (vbox), buttonbox, TRUE, TRUE, 0);
1811: snap_save_widget = make_button ("Save state", buttonbox, did_savestate);
1812: snap_load_widget = make_button ("Load state", buttonbox, did_loadstate);
1813:
1.1.1.2 root 1814: /* Place a separator below those buttons. */
1.1 root 1815: thing = gtk_hseparator_new ();
1816: gtk_box_pack_start (GTK_BOX (vbox), thing, FALSE, TRUE, 0);
1817: gtk_widget_show (thing);
1818:
1.1.1.2 root 1819: /* Now the notebook */
1.1 root 1820: notebook = gtk_notebook_new ();
1.1.1.2 root 1821: gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
1.1 root 1822: gtk_widget_show (notebook);
1823:
1.1.1.2 root 1824: for (i = 0; i < sizeof pages / sizeof (struct _pages); i++) {
1825: thing = gtk_vbox_new (FALSE, 4);
1826: gtk_widget_show (thing);
1.1.1.4 root 1827: gtk_container_set_border_width (GTK_CONTAINER (thing), 10);
1.1.1.2 root 1828: pages[i].createfunc (thing);
1829: gtk_notebook_append_page (GTK_NOTEBOOK (notebook), thing, gtk_label_new (pages[i].title));
1830: }
1.1 root 1831:
1.1.1.11 root 1832: /* Put "about" screen first. */
1833: gtk_notebook_set_page (GTK_NOTEBOOK (notebook), i - 1);
1.1 root 1834: enable_disk_buttons (1);
1.1.1.11 root 1835: enable_snap_buttons (1);
1.1 root 1836:
1837: gtk_widget_show (vbox);
1838:
1839: filesel_active = -1;
1.1.1.10 root 1840: snapsel_active = -1;
1841:
1.1 root 1842: gtk_timeout_add (1000, (GtkFunction)my_idle, 0);
1.1.1.11 root 1843: }
1844:
1845: static void *gtk_gui_thread (void *dummy)
1846: {
1.1.1.18! root 1847: gui_available = 1;
1.1 root 1848: gtk_main ();
1.1.1.11 root 1849:
1.1 root 1850: quitted_gui = 1;
1851: uae_sem_post (&gui_quit_sem);
1852: return 0;
1853: }
1854:
1855: void gui_changesettings(void)
1856: {
1857: }
1858:
1.1.1.4 root 1859: void gui_fps (int x)
1860: {
1861: }
1862:
1.1.1.18! root 1863: void gui_display (int shortcut)
! 1864: {
! 1865: }
! 1866:
1.1.1.4 root 1867: void gui_led (int num, int on)
1.1 root 1868: {
1869: if (no_gui)
1870: return;
1871:
1872: /* if (num == 0)
1873: return;
1874: printf("LED %d %d\n", num, on);
1875: write_comm_pipe_int (&to_gui_pipe, 1, 0);
1876: write_comm_pipe_int (&to_gui_pipe, num == 0 ? 4 : num - 1, 0);
1877: write_comm_pipe_int (&to_gui_pipe, on, 1);
1878: printf("#LED %d %d\n", num, on);*/
1879: }
1880:
1.1.1.11 root 1881: void gui_filename (int num, const char *name)
1.1 root 1882: {
1883: if (no_gui)
1884: return;
1885:
1.1.1.18! root 1886: write_comm_pipe_int (&to_gui_pipe, GUICMD_DISKCHANGE, 0);
1.1 root 1887: write_comm_pipe_int (&to_gui_pipe, num, 1);
1888:
1889: /* gui_update ();*/
1890: }
1891:
1.1.1.10 root 1892: void gui_handle_events (void)
1.1 root 1893: {
1.1.1.6 root 1894: int pause_uae = FALSE;
1.1.1.18! root 1895:
1.1 root 1896: if (no_gui)
1897: return;
1898:
1.1.1.6 root 1899: do {
1.1.1.18! root 1900: while (pause_uae || comm_pipe_has_data (&from_gui_pipe)) {
! 1901: int cmd = read_comm_pipe_int_blocking (&from_gui_pipe);
! 1902: int n;
! 1903: switch (cmd) {
1.1.1.11 root 1904: case 0:
1905: n = read_comm_pipe_int_blocking (&from_gui_pipe);
1906: changed_prefs.df[n][0] = '\0';
1907: break;
1908: case 1:
1909: n = read_comm_pipe_int_blocking (&from_gui_pipe);
1910: uae_sem_wait (&gui_sem);
1911: strncpy (changed_prefs.df[n], new_disk_string[n], 255);
1912: free (new_disk_string[n]);
1.1.1.13 root 1913: new_disk_string[n] = 0;
1.1.1.11 root 1914: changed_prefs.df[n][255] = '\0';
1915: uae_sem_post (&gui_sem);
1916: break;
1917: case 2:
1.1.1.18! root 1918: uae_reset (1);
1.1.1.11 root 1919: end_pause_uae ();
1920: break;
1921: case 3:
1922: activate_debugger ();
1923: end_pause_uae ();
1924: break;
1925: case 4:
1926: uae_quit ();
1927: end_pause_uae ();
1928: break;
1929: case 5:
1930: pause_uae = TRUE;
1931: break;
1932: case 6:
1933: pause_uae = FALSE;
1934: break;
1.1.1.10 root 1935: case 7:
1936: printf ("STATESAVE\n");
1.1.1.11 root 1937: savestate_state = read_comm_pipe_int_blocking (&from_gui_pipe);
1938: uae_sem_wait (&gui_sem);
1939: savestate_filename = gui_snapname;
1940: uae_sem_post (&gui_sem);
1941: break;
1942: case 8:
1943: uae_sem_wait (&gui_sem);
1944: strncpy (changed_prefs.romfile, gui_romname, 255);
1945: changed_prefs.romfile[255] = '\0';
1946: free (gui_romname);
1947: uae_sem_post (&gui_sem);
1948: break;
1949: case 9:
1950: uae_sem_wait (&gui_sem);
1951: strncpy (changed_prefs.keyfile, gui_keyname, 255);
1952: changed_prefs.keyfile[255] = '\0';
1953: free (gui_keyname);
1954: uae_sem_post (&gui_sem);
1.1.1.10 root 1955: break;
1.1.1.18! root 1956: }
! 1957: }
1.1.1.6 root 1958: } while (pause_uae);
1.1 root 1959: }
1.1.1.7 root 1960:
1961: void gui_update_gfx (void)
1962: {
1963: #if 0 /* This doesn't work... */
1964: set_gfx_state ();
1965: #endif
1966: }
1.1.1.11 root 1967:
1968: int gui_init (void)
1969: {
1970: uae_thread_id tid;
1971:
1972: gui_active = 0;
1.1.1.18! root 1973:
1.1.1.11 root 1974: init_comm_pipe (&to_gui_pipe, 20, 1);
1975: init_comm_pipe (&from_gui_pipe, 20, 1);
1976: uae_sem_init (&gui_sem, 0, 1);
1977: uae_sem_init (&gui_init_sem, 0, 0);
1978: uae_sem_init (&gui_quit_sem, 0, 0);
1979:
1980: create_guidlg ();
1981: uae_start_thread (gtk_gui_thread, NULL, &tid);
1982: gui_update ();
1983:
1984: if (currprefs.start_gui == 1) {
1.1.1.18! root 1985: write_comm_pipe_int (&to_gui_pipe, GUICMD_PAUSE, 1);
1.1.1.11 root 1986: write_comm_pipe_int (&from_gui_pipe, 5, 1);
1987: /* Handle events until Pause is unchecked. */
1988: gui_handle_events ();
1989: /* Quit requested? */
1990: if (quit_program == -1) {
1991: gui_exit ();
1992: return -2;
1993: }
1994: }
1995:
1996: return 1;
1997: }
1998:
1999: int gui_update (void)
2000: {
2001: if (no_gui)
2002: return 0;
2003:
1.1.1.18! root 2004: write_comm_pipe_int (&to_gui_pipe, GUICMD_UPDATE, 1);
1.1.1.11 root 2005: uae_sem_wait (&gui_init_sem);
2006: return 0;
2007: }
2008:
2009: void gui_exit (void)
2010: {
2011: if (no_gui)
2012: return;
2013:
2014: quit_gui = 1;
2015: uae_sem_wait (&gui_quit_sem);
2016: }
1.1.1.13 root 2017:
2018: void gui_lock (void)
2019: {
1.1.1.14 root 2020: if (no_gui)
2021: return;
1.1.1.13 root 2022: uae_sem_wait (&gui_sem);
2023: }
2024:
2025: void gui_unlock (void)
2026: {
1.1.1.14 root 2027: if (no_gui)
2028: return;
1.1.1.13 root 2029: uae_sem_post (&gui_sem);
2030: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.