32 |
|
#include "xpram.h" |
33 |
|
#include "prefs.h" |
34 |
|
#include "prefs_editor.h" |
35 |
+ |
#include "util_windows.h" |
36 |
|
#include "b2ether/inc/b2ether_hl.h" |
37 |
|
|
38 |
|
|
67 |
|
STR_SERIALB_CTRL = STR_SERPORTB_CTRL, |
68 |
|
}; |
69 |
|
#else |
70 |
+ |
#define DISABLE_SCSI 1 /* XXX merge code from original Basilisk II for Windows */ |
71 |
|
#define PROGRAM_NAME "BasiliskII" |
72 |
|
#endif |
73 |
|
|
118 |
|
return button; |
119 |
|
} |
120 |
|
|
121 |
< |
static void add_menu_item(GtkWidget *menu, int label_id, GtkSignalFunc func) |
121 |
> |
static void add_menu_item(GtkWidget *menu, const char *label, GtkSignalFunc func, gpointer data = NULL) |
122 |
|
{ |
123 |
< |
GtkWidget *item = gtk_menu_item_new_with_label(GetString(label_id)); |
123 |
> |
GtkWidget *item = gtk_menu_item_new_with_label(label); |
124 |
|
gtk_widget_show(item); |
125 |
< |
gtk_signal_connect(GTK_OBJECT(item), "activate", func, NULL); |
125 |
> |
gtk_signal_connect(GTK_OBJECT(item), "activate", func, data); |
126 |
|
gtk_menu_append(GTK_MENU(menu), item); |
127 |
|
} |
128 |
|
|
129 |
+ |
static void add_menu_item(GtkWidget *menu, int label_id, GtkSignalFunc func) |
130 |
+ |
{ |
131 |
+ |
add_menu_item(menu, GetString(label_id), func, NULL); |
132 |
+ |
} |
133 |
+ |
|
134 |
|
static GtkWidget *make_pane(GtkWidget *notebook, int title_id) |
135 |
|
{ |
136 |
|
GtkWidget *frame, *label, *box; |
465 |
|
{(gchar *)GetString(STR_HELP_ITEM_ABOUT_GTK), "<control>H", GTK_SIGNAL_FUNC(cb_about), 0, NULL} |
466 |
|
}; |
467 |
|
|
468 |
+ |
void PrefsMigrate(void) |
469 |
+ |
{ |
470 |
+ |
// Ethernet |
471 |
+ |
const char *ether = PrefsFindString("ether"); |
472 |
+ |
if (ether && ether[0] == '{') { |
473 |
+ |
PrefsReplaceString("etherguid", ether); |
474 |
+ |
PrefsReplaceString("ether", "b2ether"); |
475 |
+ |
} |
476 |
+ |
if (PrefsFindBool("routerenabled")) { |
477 |
+ |
PrefsRemoveItem("etherguid"); |
478 |
+ |
PrefsReplaceString("ether", "router"); |
479 |
+ |
} |
480 |
+ |
} |
481 |
+ |
|
482 |
|
bool PrefsEditor(void) |
483 |
|
{ |
484 |
|
// Create window |
511 |
|
gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, 0); |
512 |
|
|
513 |
|
create_volumes_pane(notebook); |
514 |
< |
// create_scsi_pane(notebook); XXX not ready yet (merge scsi_windows.cpp from original B2/Win) |
514 |
> |
#ifndef DISABLE_SCSI |
515 |
> |
create_scsi_pane(notebook); |
516 |
> |
#endif |
517 |
|
create_graphics_pane(notebook); |
518 |
|
create_input_pane(notebook); |
519 |
|
create_serial_pane(notebook); |
1342 |
|
* "Ethernet" pane |
1343 |
|
*/ |
1344 |
|
|
1322 |
– |
static GtkWidget *w_ether; |
1345 |
|
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 "; |
1346 |
|
|
1347 |
|
// Set sensitivity of widgets |
1348 |
|
static void set_ethernet_sensitive(void) |
1349 |
|
{ |
1350 |
< |
const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether)); |
1350 |
> |
const char *str = PrefsFindString("ether"); |
1351 |
|
|
1352 |
< |
bool is_nat_router = strcmp(str, s_nat_router) == 0; |
1353 |
< |
gtk_widget_set_sensitive(w_ftp_port_list, is_nat_router); |
1354 |
< |
gtk_widget_set_sensitive(w_tcp_port_list, is_nat_router); |
1352 |
> |
bool is_router = str && strcmp(str, "router") == 0; |
1353 |
> |
gtk_widget_set_sensitive(w_ftp_port_list, is_router); |
1354 |
> |
gtk_widget_set_sensitive(w_tcp_port_list, is_router); |
1355 |
|
} |
1356 |
|
|
1357 |
|
// Read settings from widgets and set preferences |
1358 |
|
static void read_ethernet_settings(void) |
1359 |
|
{ |
1360 |
< |
const char *str = gtk_entry_get_text(GTK_ENTRY(w_ether)); |
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"); |
1360 |
> |
const char *str = PrefsFindString("ether"); |
1361 |
|
|
1362 |
< |
const bool router_enabled = str && strcmp(str, s_nat_router) == 0; |
1363 |
< |
PrefsReplaceBool("routerenabled", router_enabled); |
1348 |
< |
if (router_enabled) { |
1362 |
> |
bool is_router = str && strcmp(str, "router") == 0; |
1363 |
> |
if (is_router) { |
1364 |
|
str = gtk_entry_get_text(GTK_ENTRY(w_ftp_port_list)); |
1365 |
|
PrefsReplaceString("ftp_port_list", str); |
1366 |
|
str = gtk_entry_get_text(GTK_ENTRY(w_tcp_port_list)); |
1374 |
|
set_ethernet_sensitive(); |
1375 |
|
} |
1376 |
|
|
1377 |
< |
// Add names of ethernet interfaces |
1378 |
< |
// XXX use radio buttons instead (None/NDIS/NAT) |
1364 |
< |
static GList *add_ether_names(void) |
1377 |
> |
// Ethernet option "None" selected |
1378 |
> |
static void mn_ether_none(void) |
1379 |
|
{ |
1380 |
< |
GList *glist = NULL; |
1381 |
< |
|
1382 |
< |
glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB)); |
1369 |
< |
glist = g_list_append(glist, (void *)s_nat_router); |
1380 |
> |
PrefsRemoveItem("ether"); |
1381 |
> |
PrefsRemoveItem("etherguid"); |
1382 |
> |
} |
1383 |
|
|
1384 |
< |
{ // Get NDIS ethernet adapters (XXX handle "ethermulticastmode") |
1385 |
< |
PacketOpenAdapter("", 0); |
1386 |
< |
{ |
1387 |
< |
ULONG sz; |
1388 |
< |
char names[1024]; |
1389 |
< |
sz = sizeof(names); |
1390 |
< |
if (PacketGetAdapterNames(NULL, names, &sz) == ERROR_SUCCESS) { |
1391 |
< |
char *p = names; |
1392 |
< |
while (*p) { |
1393 |
< |
const char DEVICE_HEADER[] = "\\Device\\B2ether_"; |
1394 |
< |
if (strnicmp(p, DEVICE_HEADER, sizeof(DEVICE_HEADER) - 1) == 0) { |
1395 |
< |
LPADAPTER fd = PacketOpenAdapter(p + sizeof(DEVICE_HEADER) - 1, 0); |
1396 |
< |
if (fd) { |
1397 |
< |
char str[256]; |
1398 |
< |
sprintf(str, "%s%s", s_ndis_tag, p + sizeof(DEVICE_HEADER) - 1); |
1399 |
< |
glist = g_list_append(glist, strdup(str)); |
1400 |
< |
PacketCloseAdapter(fd); |
1384 |
> |
// Ethernet option "Basilisk II Router" selected |
1385 |
> |
static void mn_ether_router(void) |
1386 |
> |
{ |
1387 |
> |
PrefsReplaceString("ether", "router"); |
1388 |
> |
PrefsRemoveItem("etherguid"); |
1389 |
> |
} |
1390 |
> |
|
1391 |
> |
// Ethernet option "Basilisk II Slirp" selected |
1392 |
> |
static void mn_ether_slirp(void) |
1393 |
> |
{ |
1394 |
> |
PrefsReplaceString("ether", "slirp"); |
1395 |
> |
PrefsRemoveItem("etherguid"); |
1396 |
> |
} |
1397 |
> |
|
1398 |
> |
// Ethernet option for Basilisk II driver selected |
1399 |
> |
static void mn_ether_b2ether(GtkWidget *, const char *guid) |
1400 |
> |
{ |
1401 |
> |
PrefsReplaceString("ether", "b2ether"); |
1402 |
> |
PrefsReplaceString("etherguid", guid); |
1403 |
> |
} |
1404 |
> |
|
1405 |
> |
// Create ethernet interfaces menu |
1406 |
> |
static int create_ether_menu(GtkWidget *menu) |
1407 |
> |
{ |
1408 |
> |
int active = -1; |
1409 |
> |
int n_items = 0; |
1410 |
> |
const char *ether = PrefsFindString("ether"); |
1411 |
> |
const char *etherguid = PrefsFindString("etherguid"); |
1412 |
> |
|
1413 |
> |
add_menu_item(menu, STR_NONE_LAB, (GtkSignalFunc)mn_ether_none); |
1414 |
> |
if (ether == NULL) |
1415 |
> |
active = n_items; |
1416 |
> |
n_items++; |
1417 |
> |
|
1418 |
> |
add_menu_item(menu, "Basilisk II Router", (GtkSignalFunc)mn_ether_router); |
1419 |
> |
if (ether && strcmp(ether, "router") == 0) |
1420 |
> |
active = n_items; |
1421 |
> |
n_items++; |
1422 |
> |
|
1423 |
> |
add_menu_item(menu, "Basilisk II Slirp", (GtkSignalFunc)mn_ether_router); |
1424 |
> |
if (ether && strcmp(ether, "slirp") == 0) |
1425 |
> |
active = n_items; |
1426 |
> |
n_items++; |
1427 |
> |
|
1428 |
> |
PacketOpenAdapter("", 0); |
1429 |
> |
{ |
1430 |
> |
ULONG sz; |
1431 |
> |
char names[1024]; |
1432 |
> |
sz = sizeof(names); |
1433 |
> |
if (PacketGetAdapterNames(NULL, names, &sz) == ERROR_SUCCESS) { |
1434 |
> |
char *p = names; |
1435 |
> |
while (*p) { |
1436 |
> |
const char DEVICE_HEADER[] = "\\Device\\B2ether_"; |
1437 |
> |
if (strnicmp(p, DEVICE_HEADER, sizeof(DEVICE_HEADER) - 1) == 0) { |
1438 |
> |
LPADAPTER fd = PacketOpenAdapter(p + sizeof(DEVICE_HEADER) - 1, 0); |
1439 |
> |
if (fd) { |
1440 |
> |
char guid[256]; |
1441 |
> |
sprintf(guid, "%s", p + sizeof(DEVICE_HEADER) - 1); |
1442 |
> |
const char *name = ether_guid_to_name(guid); |
1443 |
> |
if (name && (name = g_locale_to_utf8(name, -1, NULL, NULL, NULL))) { |
1444 |
> |
add_menu_item(menu, name, (GtkSignalFunc)mn_ether_b2ether, strdup(guid)); |
1445 |
> |
if (etherguid && strcmp(guid, etherguid) == 0 && |
1446 |
> |
ether && strcmp(ether, "b2ether") == 0) |
1447 |
> |
active = n_items; |
1448 |
> |
n_items++; |
1449 |
|
} |
1450 |
+ |
PacketCloseAdapter(fd); |
1451 |
|
} |
1390 |
– |
p += strlen(p) + 1; |
1452 |
|
} |
1453 |
+ |
p += strlen(p) + 1; |
1454 |
|
} |
1455 |
|
} |
1394 |
– |
PacketCloseAdapter(NULL); |
1456 |
|
} |
1457 |
< |
return glist; |
1397 |
< |
} |
1457 |
> |
PacketCloseAdapter(NULL); |
1458 |
|
|
1459 |
+ |
return active; |
1460 |
+ |
} |
1461 |
|
|
1462 |
|
// Create "Ethernet" pane |
1463 |
|
static void create_ethernet_pane(GtkWidget *top) |
1464 |
|
{ |
1465 |
< |
GtkWidget *box, *hbox, *table, *label, *combo, *sep, *entry; |
1465 |
> |
GtkWidget *box, *hbox, *table, *label, *sep, *entry, *opt, *menu, *item; |
1466 |
|
|
1467 |
|
box = make_pane(top, STR_NETWORK_PANE_TITLE); |
1468 |
|
table = make_table(box, 2, 5); |
1471 |
|
gtk_widget_show(label); |
1472 |
|
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1473 |
|
|
1474 |
< |
GList *glist = add_ether_names(); |
1475 |
< |
combo = gtk_combo_new(); |
1476 |
< |
gtk_widget_show(combo); |
1477 |
< |
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist); |
1478 |
< |
const char *str = PrefsFindString("ether"); |
1479 |
< |
if (str == NULL || str[0] == '\0') { |
1480 |
< |
if (PrefsFindBool("routerenabled")) |
1481 |
< |
str = s_nat_router; |
1482 |
< |
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; |
1431 |
< |
gtk_signal_connect(GTK_OBJECT(w_ether), "changed", GTK_SIGNAL_FUNC(cb_ether_changed), NULL); |
1474 |
> |
opt = gtk_option_menu_new(); |
1475 |
> |
gtk_widget_show(opt); |
1476 |
> |
menu = gtk_menu_new(); |
1477 |
> |
int active = create_ether_menu(menu); |
1478 |
> |
if (active >= 0) |
1479 |
> |
gtk_menu_set_active(GTK_MENU(menu), active); |
1480 |
> |
gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu); |
1481 |
> |
gtk_table_attach(GTK_TABLE(table), opt, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL | GTK_EXPAND), (GtkAttachOptions)0, 4, 4); |
1482 |
> |
gtk_signal_connect(GTK_OBJECT(opt), "changed", GTK_SIGNAL_FUNC(cb_ether_changed), NULL); |
1483 |
|
|
1484 |
|
sep = gtk_hseparator_new(); |
1485 |
|
gtk_widget_show(sep); |
1490 |
|
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); |
1491 |
|
|
1492 |
|
entry = gtk_entry_new(); |
1493 |
< |
str = PrefsFindString("ftp_port_list"); |
1493 |
> |
const char *str = PrefsFindString("ftp_port_list"); |
1494 |
|
if (str == NULL) |
1495 |
|
str = ""; |
1496 |
|
gtk_entry_set_text(GTK_ENTRY(entry), str); |
1523 |
|
static GtkWidget *w_rom_file; |
1524 |
|
|
1525 |
|
// Don't use CPU when idle? |
1475 |
– |
#ifdef SHEEPSHAVER |
1526 |
|
static void tb_idlewait(GtkWidget *widget) |
1527 |
|
{ |
1528 |
|
PrefsReplaceBool("idlewait", GTK_TOGGLE_BUTTON(widget)->active); |
1529 |
|
} |
1480 |
– |
#endif |
1530 |
|
|
1531 |
|
// "Ignore SEGV" button toggled |
1532 |
|
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION |
1626 |
|
|
1627 |
|
w_rom_file = table_make_file_entry(table, 4, STR_ROM_FILE_CTRL, "rom"); |
1628 |
|
|
1629 |
+ |
make_checkbox(box, STR_IDLEWAIT_CTRL, "idlewait", GTK_SIGNAL_FUNC(tb_idlewait)); |
1630 |
+ |
|
1631 |
|
#ifdef HAVE_SIGSEGV_SKIP_INSTRUCTION |
1632 |
|
make_checkbox(box, STR_IGNORESEGV_CTRL, "ignoresegv", GTK_SIGNAL_FUNC(tb_ignoresegv)); |
1633 |
|
#endif |
1583 |
– |
|
1584 |
– |
#ifdef SHEEPSHAVER |
1585 |
– |
make_checkbox(box, STR_IDLEWAIT_CTRL, "idlewait", GTK_SIGNAL_FUNC(tb_idlewait)); |
1586 |
– |
#endif |
1634 |
|
} |
1635 |
|
|
1636 |
|
|
1658 |
|
uint8 XPRAM[XPRAM_SIZE]; |
1659 |
|
void MountVolume(void *fh) { } |
1660 |
|
void FileDiskLayout(loff_t size, uint8 *data, loff_t &start_byte, loff_t &real_size) { } |
1614 |
– |
void WarningAlert(const char *text) { } |
1661 |
|
void recycle_write_packet(LPPACKET) { } |
1662 |
|
VOID CALLBACK packet_read_completion(DWORD, DWORD, LPOVERLAPPED) { } |
1663 |
|
|
1682 |
|
MessageBox(NULL, text, GetString(title_id), MB_OK | flags); |
1683 |
|
} |
1684 |
|
|
1685 |
< |
static void ErrorAlert(const char *text) |
1685 |
> |
void ErrorAlert(const char *text) |
1686 |
|
{ |
1687 |
|
display_alert(STR_ERROR_ALERT_TITLE, text, MB_ICONSTOP); |
1688 |
|
} |
1689 |
|
|
1690 |
+ |
void WarningAlert(const char *text) |
1691 |
+ |
{ |
1692 |
+ |
display_alert(STR_WARNING_ALERT_TITLE, text, MB_ICONSTOP); |
1693 |
+ |
} |
1694 |
+ |
|
1695 |
|
|
1696 |
|
/* |
1697 |
|
* Start standalone GUI |
1706 |
|
// Read preferences |
1707 |
|
PrefsInit(argc, argv); |
1708 |
|
|
1709 |
+ |
// Migrate preferences |
1710 |
+ |
PrefsMigrate(); |
1711 |
+ |
|
1712 |
|
// Show preferences editor |
1713 |
|
bool start = PrefsEditor(); |
1714 |
|
|