ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Windows/prefs_editor_gtk.cpp
(Generate patch)

Comparing BasiliskII/src/Windows/prefs_editor_gtk.cpp (file contents):
Revision 1.6 by gbeauche, 2005-11-20T23:59:18Z vs.
Revision 1.10 by gbeauche, 2005-11-29T22:59:44Z

# Line 32 | Line 32
32   #include "xpram.h"
33   #include "prefs.h"
34   #include "prefs_editor.h"
35 + #include "b2ether/inc/b2ether_hl.h"
36  
37  
38   // Global variables
# Line 52 | Line 53 | static void read_settings(void);
53  
54  
55   /*
56 + *  SheepShaver glue
57 + */
58 +
59 + #ifdef SHEEPSHAVER
60 + #define DISABLE_SCSI 1
61 + #define PROGRAM_NAME "SheepShaver"
62 + enum {
63 +        STR_WINDOW_LAB = STR_WINDOW_CTRL,
64 +        STR_FULLSCREEN_LAB = STR_FULLSCREEN_CTRL,
65 +        STR_SERIALA_CTRL = STR_SERPORTA_CTRL,
66 +        STR_SERIALB_CTRL = STR_SERPORTB_CTRL,
67 + };
68 + #else
69 + #define PROGRAM_NAME "BasiliskII"
70 + #endif
71 +
72 +
73 + /*
74   *  Utility functions
75   */
76  
# Line 305 | Line 324 | static GtkWidget *make_checkbox(GtkWidge
324          return button;
325   }
326  
327 < static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *prefs_item, const combo_desc *options)
327 > static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *default_value, GList *glist)
328   {
329          GtkWidget *box, *label, *combo;
311        char str[32];
330  
331          box = gtk_hbox_new(FALSE, 4);
332          gtk_widget_show(box);
# Line 317 | Line 335 | static GtkWidget *make_combobox(GtkWidge
335          label = gtk_label_new(GetString(label_id));
336          gtk_widget_show(label);
337          gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
320
321        GList *glist = NULL;
322        while (options->label_id) {
323                glist = g_list_append(glist, (void *)GetString(options->label_id));
324                options++;
325        }
338          
339          combo = gtk_combo_new();
340          gtk_widget_show(combo);
341          gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist);
342          
343 <        sprintf(str, "%d", PrefsFindInt32(prefs_item));
332 <        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str);
343 >        gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), default_value);
344          gtk_box_pack_start(GTK_BOX(box), combo, TRUE, TRUE, 0);
345          
346          return combo;
347   }
348  
349 + static GtkWidget *make_combobox(GtkWidget *top, int label_id, const char *default_value, const combo_desc *options)
350 + {
351 +        GList *glist = NULL;
352 +        while (options->label_id) {
353 +                glist = g_list_append(glist, (void *)GetString(options->label_id));
354 +                options++;
355 +        }
356 +
357 +        return make_combobox(top, label_id, default_value, glist);
358 + }
359 +
360  
361   /*
362   *  Show preferences editor
# Line 390 | Line 412 | static void cb_about(...)
412  
413          char str[512];
414          sprintf(str,
415 <                "Basilisk II\nVersion %d.%d\n\n"
415 >                PROGRAM_NAME "\nVersion %d.%d\n\n"
416                  "Copyright (C) 1997-2005 Christian Bauer et al.\n"
417 <                "E-mail: Christian.Bauer@uni-mainz.de\n"
418 <                "http://www.uni-mainz.de/~bauec002/B2Main.html\n\n"
419 <                "Basilisk II comes with ABSOLUTELY NO\n"
417 >                "E-mail: cb@cebix.net\n"
418 > #ifdef SHEEPSHAVER
419 >                "http://sheepshaver.cebix.net/\n\n"
420 > #else
421 >                "http://basilisk.cebix.net/\n\n"
422 > #endif
423 >                PROGRAM_NAME " comes with ABSOLUTELY NO\n"
424                  "WARRANTY. This is free software, and\n"
425                  "you are welcome to redistribute it\n"
426                  "under the terms of the GNU General\n"
# Line 490 | Line 516 | bool PrefsEditor(void)
516   *  "Volumes" pane
517   */
518  
519 < static GtkWidget *w_enableextfs, *w_extdrives;
519 > static GtkWidget *w_enableextfs, *w_extdrives, *w_cdrom_drive;
520   static GtkWidget *volume_list;
521   static int selected_volume;
522  
# Line 499 | Line 525 | static void set_volumes_sensitive(void)
525   {
526          const bool enable_extfs = PrefsFindBool("enableextfs");
527          gtk_widget_set_sensitive(w_extdrives, enable_extfs);
528 +        const bool no_cdrom = PrefsFindBool("nocdrom");
529 +        gtk_widget_set_sensitive(w_cdrom_drive, !no_cdrom);
530   }
531  
532   // Volume in list selected
# Line 589 | Line 617 | static void tb_enableextfs(GtkWidget *wi
617   static void tb_nocdrom(GtkWidget *widget)
618   {
619          PrefsReplaceBool("nocdrom", GTK_TOGGLE_BUTTON(widget)->active);
620 +        set_volumes_sensitive();
621 + }
622 +
623 + // Add names of CD-ROM devices
624 + static GList *add_cdrom_names(void)
625 + {
626 +        GList *glist = NULL;
627 +
628 +        char rootdir[4] = "X:\\";
629 +        for (char letter = 'C'; letter <= 'Z'; letter++) {
630 +                rootdir[0] = letter;
631 +                if (GetDriveType(rootdir) == DRIVE_CDROM)
632 +                        glist = g_list_append(glist, strdup(rootdir));
633 +        }
634 +
635 +        return glist;
636   }
637  
638   // "Enable polling" button toggled
# Line 609 | Line 653 | static void read_volumes_settings(void)
653                  PrefsAddString("disk", str);
654          }
655  
656 +        const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_cdrom_drive)->entry));
657 +        if (str && strlen(str))
658 +                PrefsReplaceString("cdrom", str);
659 +        else
660 +                PrefsRemoveItem("cdrom");
661 +
662          PrefsReplaceString("extdrives", get_file_entry_path(w_extdrives));
663   }
664  
# Line 659 | Line 709 | static void create_volumes_pane(GtkWidge
709  
710          make_checkbox(box, STR_NOCDROM_CTRL, "nocdrom", GTK_SIGNAL_FUNC(tb_nocdrom));
711  
712 +        GList *glist = add_cdrom_names();
713 +        str = const_cast<char *>(PrefsFindString("cdrom"));
714 +        if (str == NULL)
715 +                str = "";
716 +        w_cdrom_drive = make_combobox(box, STR_CDROM_DRIVE_CTRL, str, glist);
717 +
718          make_checkbox(box, STR_POLLMEDIA_CTRL, "pollmedia", GTK_SIGNAL_FUNC(tb_pollmedia));
719  
720          make_separator(box);
# Line 673 | Line 729 | static void create_volumes_pane(GtkWidge
729   *  "JIT Compiler" pane
730   */
731  
732 + #ifndef SHEEPSHAVER
733   static GtkWidget *w_jit_fpu;
734   static GtkWidget *w_jit_atraps;
735   static GtkWidget *w_jit_cache_size;
736   static GtkWidget *w_jit_lazy_flush;
737   static GtkWidget *w_jit_follow_const_jumps;
738 + #endif
739  
740   // Set sensitivity of widgets
741   static void set_jit_sensitive(void)
742   {
743 + #ifndef SHEEPSHAVER
744          const bool jit_enabled = PrefsFindBool("jit");
745          gtk_widget_set_sensitive(w_jit_fpu, jit_enabled);
746          gtk_widget_set_sensitive(w_jit_cache_size, jit_enabled);
747          gtk_widget_set_sensitive(w_jit_lazy_flush, jit_enabled);
748          gtk_widget_set_sensitive(w_jit_follow_const_jumps, jit_enabled);
749 + #endif
750   }
751  
752   // "Use JIT Compiler" button toggled
# Line 697 | Line 757 | static void tb_jit(GtkWidget *widget)
757   }
758  
759   // "Compile FPU Instructions" button toggled
760 + #ifndef SHEEPSHAVER
761   static void tb_jit_fpu(GtkWidget *widget)
762   {
763          PrefsReplaceBool("jitfpu", GTK_TOGGLE_BUTTON(widget)->active);
764   }
765 + #endif
766  
767   // "Lazy translation cache invalidation" button toggled
768 + #ifndef SHEEPSHAVER
769   static void tb_jit_lazy_flush(GtkWidget *widget)
770   {
771          PrefsReplaceBool("jitlazyflush", GTK_TOGGLE_BUTTON(widget)->active);
772   }
773 + #endif
774  
775   // "Translate through constant jumps (inline blocks)" button toggled
776 + #ifndef SHEEPSHAVER
777   static void tb_jit_follow_const_jumps(GtkWidget *widget)
778   {
779          PrefsReplaceBool("jitinline", GTK_TOGGLE_BUTTON(widget)->active);
780   }
781 + #endif
782  
783   // Read settings from widgets and set preferences
784   static void read_jit_settings(void)
# Line 720 | Line 786 | static void read_jit_settings(void)
786   #if USE_JIT
787          bool jit_enabled = PrefsFindBool("jit");
788          if (jit_enabled) {
789 + #ifndef SHEEPSHAVER
790                  const char *str = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(w_jit_cache_size)->entry));
791                  PrefsReplaceInt32("jitcachesize", atoi(str));
792 + #endif
793          }
794   #endif
795   }
796  
797 + // "Use built-in 68k DR emulator" button toggled
798 + #ifdef SHEEPSHAVER
799 + static void tb_jit_68k(GtkWidget *widget)
800 + {
801 +        PrefsReplaceBool("jit68k", GTK_TOGGLE_BUTTON(widget)->active);
802 + }
803 + #endif
804 +
805   // Create "JIT Compiler" pane
806   static void create_jit_pane(GtkWidget *top)
807   {
# Line 736 | Line 812 | static void create_jit_pane(GtkWidget *t
812          box = make_pane(top, STR_JIT_PANE_TITLE);
813          make_checkbox(box, STR_JIT_CTRL, "jit", GTK_SIGNAL_FUNC(tb_jit));
814          
815 + #ifndef SHEEPSHAVER
816          w_jit_fpu = make_checkbox(box, STR_JIT_FPU_CTRL, "jitfpu", GTK_SIGNAL_FUNC(tb_jit_fpu));
817          
818          // Translation cache size
# Line 746 | Line 823 | static void create_jit_pane(GtkWidget *t
823                  STR_JIT_CACHE_SIZE_16MB_LAB,
824                  0
825          };
826 <        w_jit_cache_size = make_combobox(box, STR_JIT_CACHE_SIZE_CTRL, "jitcachesize", options);
826 >        sprintf(str, "%d", PrefsFindInt32("jitcachesize"));
827 >        w_jit_cache_size = make_combobox(box, STR_JIT_CACHE_SIZE_CTRL, str, options);
828          
829          // Lazy translation cache invalidation
830          w_jit_lazy_flush = make_checkbox(box, STR_JIT_LAZY_CINV_CTRL, "jitlazyflush", GTK_SIGNAL_FUNC(tb_jit_lazy_flush));
831  
832          // Follow constant jumps (inline basic blocks)
833          w_jit_follow_const_jumps = make_checkbox(box, STR_JIT_FOLLOW_CONST_JUMPS, "jitinline", GTK_SIGNAL_FUNC(tb_jit_follow_const_jumps));
834 + #endif
835  
836          set_jit_sensitive();
837   #endif
838 +
839 + #ifdef SHEEPSHAVER
840 +        make_checkbox(box, STR_JIT_68K_CTRL, "jit68k", GTK_SIGNAL_FUNC(tb_jit_68k));
841 + #endif
842   }
843  
844   /*
# Line 767 | Line 850 | static GtkWidget *w_scsi[7];
850   // Read settings from widgets and set preferences
851   static void read_scsi_settings(void)
852   {
853 + #ifndef DISABLE_SCSI
854          for (int id=0; id<7; id++) {
855                  char prefs_name[32];
856                  sprintf(prefs_name, "scsi%d", id);
# Line 776 | Line 860 | static void read_scsi_settings(void)
860                  else
861                          PrefsRemoveItem(prefs_name);
862          }
863 + #endif
864   }
865  
866   // Create "SCSI" pane
867   static void create_scsi_pane(GtkWidget *top)
868   {
869 + #ifndef DISABLE_SCSI
870          GtkWidget *box;
871  
872          box = make_pane(top, STR_SCSI_PANE_TITLE);
# Line 790 | Line 876 | static void create_scsi_pane(GtkWidget *
876                  sprintf(prefs_name, "scsi%d", id);
877                  w_scsi[id] = make_file_entry(box, STR_SCSI_ID_0 + id, prefs_name);
878          }
879 + #endif
880   }
881  
882  
# Line 833 | Line 920 | static void mn_fullscreen(...)
920   {
921          display_type = DISPLAY_SCREEN;
922          hide_show_graphics_widgets();
923 +        PrefsReplaceInt32("frameskip", 1);
924   }
925  
926   // "5 Hz".."60Hz" selected
# Line 844 | Line 932 | static void mn_30hz(...) {PrefsReplaceIn
932   static void mn_60hz(...) {PrefsReplaceInt32("frameskip", 1);}
933   static void mn_dynamic(...) {PrefsReplaceInt32("frameskip", 0);}
934  
935 + // QuickDraw acceleration
936 + #ifdef SHEEPSHAVER
937 + static void tb_gfxaccel(GtkWidget *widget)
938 + {
939 +        PrefsReplaceBool("gfxaccel", GTK_TOGGLE_BUTTON(widget)->active);
940 + }
941 + #endif
942 +
943   // Set sensitivity of widgets
944   static void set_graphics_sensitive(void)
945   {
# Line 861 | Line 957 | static void tb_nosound(GtkWidget *widget
957   static void parse_graphics_prefs(void)
958   {
959          display_type = DISPLAY_WINDOW;
960 + #ifdef SHEEPSHAVER
961 +        dis_width = 640;
962 +        dis_height = 480;
963 + #else
964          dis_width = 512;
965          dis_height = 384;
966 + #endif
967  
968          const char *str = PrefsFindString("screen");
969          if (str) {
# Line 1002 | Line 1103 | static void create_graphics_pane(GtkWidg
1103          gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 3, 4, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4);
1104          w_display_y = GTK_COMBO(combo)->entry;
1105  
1106 + #ifdef SHEEPSHAVER
1107 +        make_checkbox(box, STR_GFXACCEL_CTRL, "gfxaccel", GTK_SIGNAL_FUNC(tb_gfxaccel));
1108 + #endif
1109 +
1110          make_separator(box);
1111          make_checkbox(box, STR_NOSOUND_CTRL, "nosound", GTK_SIGNAL_FUNC(tb_nosound));
1112  
# Line 1217 | Line 1322 | static void create_serial_pane(GtkWidget
1322   static GtkWidget *w_ether;
1323   static GtkWidget *w_ftp_port_list, *w_tcp_port_list;
1324   static const char s_nat_router[] = "NAT/Router module";
1325 + static const char s_ndis_tag[] = "NDIS ";
1326  
1327   // Set sensitivity of widgets
1328   static void set_ethernet_sensitive(void)
# Line 1232 | Line 1338 | static void set_ethernet_sensitive(void)
1338   static void read_ethernet_settings(void)
1339   {
1340          const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether));
1341 <        if (str && strlen(str) > 6 && strncmp(str, "NDIS: ", 6) == 0)
1342 <                PrefsReplaceString("ether", &str[6]);
1341 >        if (str && strlen(str) > sizeof(s_ndis_tag) && strncmp(str, s_ndis_tag, sizeof(s_ndis_tag) - 1) == 0)
1342 >                PrefsReplaceString("ether", &str[sizeof(s_ndis_tag) - 1]);
1343          else
1344                  PrefsRemoveItem("ether");
1345  
# Line 1254 | Line 1360 | static void cb_ether_changed(...)
1360   }
1361  
1362   // Add names of ethernet interfaces
1363 + // XXX use radio buttons instead (None/NDIS/NAT)
1364   static GList *add_ether_names(void)
1365   {
1366          GList *glist = NULL;
1367  
1261        // TODO: Get list of all Ethernet interfaces
1262 #ifdef HAVE_SLIRP
1263        static const char s_slirp[] = "slirp";
1264        glist = g_list_append(glist, (void *)s_slirp);
1265 #endif
1266        glist = g_list_append(glist, (void *)s_nat_router);
1368          glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB));
1369 +        glist = g_list_append(glist, (void *)s_nat_router);
1370 +
1371 +        {       // Get NDIS ethernet adapters (XXX handle "ethermulticastmode")
1372 +                PacketOpenAdapter("", 0);
1373 +                {
1374 +                        ULONG sz;
1375 +                        char names[1024];
1376 +                        sz = sizeof(names);
1377 +                        if (PacketGetAdapterNames(NULL, names, &sz) == ERROR_SUCCESS) {
1378 +                                char *p = names;
1379 +                                while (*p) {
1380 +                                        const char DEVICE_HEADER[] = "\\Device\\B2ether_";
1381 +                                        if (strnicmp(p, DEVICE_HEADER, sizeof(DEVICE_HEADER) - 1) == 0) {
1382 +                                                LPADAPTER fd = PacketOpenAdapter(p + sizeof(DEVICE_HEADER) - 1, 0);
1383 +                                                if (fd) {
1384 +                                                        char str[256];
1385 +                                                        sprintf(str, "%s%s", s_ndis_tag, p + sizeof(DEVICE_HEADER) - 1);
1386 +                                                        glist = g_list_append(glist, strdup(str));
1387 +                                                        PacketCloseAdapter(fd);
1388 +                                                }
1389 +                                        }
1390 +                                        p += strlen(p) + 1;
1391 +                                }
1392 +                        }
1393 +                }
1394 +                PacketCloseAdapter(NULL);
1395 +        }
1396          return glist;
1397   }
1398  
# Line 1292 | Line 1420 | static void create_ethernet_pane(GtkWidg
1420                  else
1421                          str = GetString(STR_NONE_LAB);
1422          }
1423 +        else if (str[0] == '{') {
1424 +                static char s_device[256];
1425 +                sprintf(s_device, "%s%s", s_ndis_tag, str);
1426 +                str = s_device;
1427 +        }
1428          gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), str);
1429          gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4);
1430          w_ether = GTK_COMBO(combo)->entry;
# Line 1338 | Line 1471 | static void create_ethernet_pane(GtkWidg
1471   static GtkWidget *w_ramsize;
1472   static GtkWidget *w_rom_file;
1473  
1474 + // Don't use CPU when idle?
1475 + #ifdef SHEEPSHAVER
1476 + static void tb_idlewait(GtkWidget *widget)
1477 + {
1478 +        PrefsReplaceBool("idlewait", GTK_TOGGLE_BUTTON(widget)->active);
1479 + }
1480 + #endif
1481 +
1482   // "Ignore SEGV" button toggled
1483   #ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
1484   static void tb_ignoresegv(GtkWidget *widget)
# Line 1380 | Line 1521 | static void create_memory_pane(GtkWidget
1521          table = make_table(box, 2, 5);
1522  
1523          static const combo_desc options[] = {
1524 + #ifndef SHEEPSHAVER
1525                  STR_RAMSIZE_2MB_LAB,
1526 + #endif
1527                  STR_RAMSIZE_4MB_LAB,
1528                  STR_RAMSIZE_8MB_LAB,
1529                  STR_RAMSIZE_16MB_LAB,
# Line 1389 | Line 1532 | static void create_memory_pane(GtkWidget
1532                  STR_RAMSIZE_128MB_LAB,
1533                  STR_RAMSIZE_256MB_LAB,
1534                  STR_RAMSIZE_512MB_LAB,
1535 + #ifndef SHEEPSHAVER
1536                  STR_RAMSIZE_1024MB_LAB,
1537 + #endif
1538                  0
1539          };
1540          char default_ramsize[10];
1541          sprintf(default_ramsize, "%d", PrefsFindInt32("ramsize") >> 20);
1542          w_ramsize = table_make_combobox(table, 0, STR_RAMSIZE_CTRL, default_ramsize, options);
1543  
1544 + #ifndef SHEEPSHAVER
1545          static const opt_desc model_options[] = {
1546                  {STR_MODELID_5_LAB, GTK_SIGNAL_FUNC(mn_modelid_5)},
1547                  {STR_MODELID_14_LAB, GTK_SIGNAL_FUNC(mn_modelid_14)},
# Line 1407 | Line 1553 | static void create_memory_pane(GtkWidget
1553                  case 14: active = 1; break;
1554          }
1555          table_make_option_menu(table, 2, STR_MODELID_CTRL, model_options, active);
1556 + #endif
1557  
1558   #if EMULATED_68K
1559          static const opt_desc cpu_options[] = {
# Line 1433 | Line 1580 | static void create_memory_pane(GtkWidget
1580   #ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION
1581          make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv));
1582   #endif
1583 +
1584 + #ifdef SHEEPSHAVER
1585 +        make_checkbox(box, STR_IDLEWAIT_CTRL, "idlewait", GTK_SIGNAL_FUNC(tb_idlewait));
1586 + #endif
1587   }
1588  
1589  
# Line 1461 | Line 1612 | uint8 XPRAM[XPRAM_SIZE];
1612   void MountVolume(void *fh) { }
1613   void FileDiskLayout(loff_t size, uint8 *data, loff_t &start_byte, loff_t &real_size) { }
1614   void WarningAlert(const char *text) { }
1615 + void recycle_write_packet(LPPACKET) { }
1616 + VOID CALLBACK packet_read_completion(DWORD, DWORD, LPOVERLAPPED) { }
1617  
1618  
1619   /*
# Line 1508 | Line 1661 | int main(int argc, char *argv[])
1661          // Exit preferences
1662          PrefsExit();
1663  
1664 <        // Transfer control to the Basilisk II executable
1664 >        // Transfer control to the executable
1665          if (start) {
1666                  char path[_MAX_PATH];
1667                  bool ok = GetModuleFileName(NULL, path, sizeof(path)) != 0;
# Line 1518 | Line 1671 | int main(int argc, char *argv[])
1671                          *++p = '\0';
1672                          SetCurrentDirectory(path);
1673                          strcpy(b2_path, path);
1674 <                        strcat(b2_path, "BasiliskII.exe");
1674 >                        strcat(b2_path, PROGRAM_NAME);
1675 >                        strcat(b2_path, ".exe");
1676                          HINSTANCE h = ShellExecute(GetDesktopWindow(), "open",
1677                                                                             b2_path, "", path, SW_SHOWNORMAL);
1678                          if ((int)h <= 32)
1679                                  ok = false;
1680                  }
1681                  if (!ok) {
1682 <                        ErrorAlert("Coult not start BasiliskII executable");
1682 >                        ErrorAlert("Coult not start " PROGRAM_NAME " executable");
1683                          return 1;
1684                  }
1685          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines