mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-10 18:29:44 +00:00
- integrated patches for NetBSD
This commit is contained in:
parent
e51085edcb
commit
62aff59d79
@ -258,13 +258,13 @@ static void mn_zap_pram(...)
|
||||
|
||||
// Menu item descriptions
|
||||
static GtkItemFactoryEntry menu_items[] = {
|
||||
{GetString(STR_PREFS_MENU_FILE_GTK), NULL, NULL, 0, "<Branch>"},
|
||||
{GetString(STR_PREFS_ITEM_START_GTK), NULL, GTK_SIGNAL_FUNC(cb_start), 0, NULL},
|
||||
{GetString(STR_PREFS_ITEM_ZAP_PRAM_GTK), NULL, GTK_SIGNAL_FUNC(mn_zap_pram), 0, NULL},
|
||||
{GetString(STR_PREFS_ITEM_SEPL_GTK), NULL, NULL, 0, "<Separator>"},
|
||||
{GetString(STR_PREFS_ITEM_QUIT_GTK), "<control>Q", GTK_SIGNAL_FUNC(cb_quit), 0, NULL},
|
||||
{GetString(STR_HELP_MENU_GTK), NULL, NULL, 0, "<LastBranch>"},
|
||||
{GetString(STR_HELP_ITEM_ABOUT_GTK), NULL, GTK_SIGNAL_FUNC(mn_about), 0, NULL}
|
||||
{(gchar *)GetString(STR_PREFS_MENU_FILE_GTK), NULL, NULL, 0, "<Branch>"},
|
||||
{(gchar *)GetString(STR_PREFS_ITEM_START_GTK), NULL, GTK_SIGNAL_FUNC(cb_start), 0, NULL},
|
||||
{(gchar *)GetString(STR_PREFS_ITEM_ZAP_PRAM_GTK), NULL, GTK_SIGNAL_FUNC(mn_zap_pram), 0, NULL},
|
||||
{(gchar *)GetString(STR_PREFS_ITEM_SEPL_GTK), NULL, NULL, 0, "<Separator>"},
|
||||
{(gchar *)GetString(STR_PREFS_ITEM_QUIT_GTK), "<control>Q", GTK_SIGNAL_FUNC(cb_quit), 0, NULL},
|
||||
{(gchar *)GetString(STR_HELP_MENU_GTK), NULL, NULL, 0, "<LastBranch>"},
|
||||
{(gchar *)GetString(STR_HELP_ITEM_ABOUT_GTK), NULL, GTK_SIGNAL_FUNC(mn_about), 0, NULL}
|
||||
};
|
||||
|
||||
bool PrefsEditor(void)
|
||||
@ -678,11 +678,11 @@ static void create_graphics_pane(GtkWidget *top)
|
||||
combo = gtk_combo_new();
|
||||
gtk_widget_show(combo);
|
||||
GList *glist1 = NULL;
|
||||
glist1 = g_list_append(glist1, GetString(STR_SIZE_512_LAB));
|
||||
glist1 = g_list_append(glist1, GetString(STR_SIZE_640_LAB));
|
||||
glist1 = g_list_append(glist1, GetString(STR_SIZE_800_LAB));
|
||||
glist1 = g_list_append(glist1, GetString(STR_SIZE_1024_LAB));
|
||||
glist1 = g_list_append(glist1, GetString(STR_SIZE_MAX_LAB));
|
||||
glist1 = g_list_append(glist1, (void *)GetString(STR_SIZE_512_LAB));
|
||||
glist1 = g_list_append(glist1, (void *)GetString(STR_SIZE_640_LAB));
|
||||
glist1 = g_list_append(glist1, (void *)GetString(STR_SIZE_800_LAB));
|
||||
glist1 = g_list_append(glist1, (void *)GetString(STR_SIZE_1024_LAB));
|
||||
glist1 = g_list_append(glist1, (void *)GetString(STR_SIZE_MAX_LAB));
|
||||
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist1);
|
||||
if (dis_width)
|
||||
sprintf(str, "%d", dis_width);
|
||||
@ -699,11 +699,11 @@ static void create_graphics_pane(GtkWidget *top)
|
||||
combo = gtk_combo_new();
|
||||
gtk_widget_show(combo);
|
||||
GList *glist2 = NULL;
|
||||
glist2 = g_list_append(glist2, GetString(STR_SIZE_384_LAB));
|
||||
glist2 = g_list_append(glist2, GetString(STR_SIZE_480_LAB));
|
||||
glist2 = g_list_append(glist2, GetString(STR_SIZE_600_LAB));
|
||||
glist2 = g_list_append(glist2, GetString(STR_SIZE_768_LAB));
|
||||
glist2 = g_list_append(glist2, GetString(STR_SIZE_MAX_LAB));
|
||||
glist2 = g_list_append(glist2, (void *)GetString(STR_SIZE_384_LAB));
|
||||
glist2 = g_list_append(glist2, (void *)GetString(STR_SIZE_480_LAB));
|
||||
glist2 = g_list_append(glist2, (void *)GetString(STR_SIZE_600_LAB));
|
||||
glist2 = g_list_append(glist2, (void *)GetString(STR_SIZE_768_LAB));
|
||||
glist2 = g_list_append(glist2, (void *)GetString(STR_SIZE_MAX_LAB));
|
||||
gtk_combo_set_popdown_strings(GTK_COMBO(combo), glist2);
|
||||
if (dis_height)
|
||||
sprintf(str, "%d", dis_height);
|
||||
@ -762,6 +762,8 @@ static GList *add_serial_names(void)
|
||||
if (strncmp(de->d_name, "ttyS", 4) == 0 || strncmp(de->d_name, "lp", 2) == 0) {
|
||||
#elif defined(__FreeBSD__)
|
||||
if (strncmp(de->d_name, "cuaa", 4) == 0 || strncmp(de->d_name, "lpt", 3) == 0) {
|
||||
#elif defined(__NetBSD__)
|
||||
if (strncmp(de->d_name, "tty0", 4) == 0 || strncmp(de->d_name, "lpt", 3) == 0) {
|
||||
#elif defined(sgi)
|
||||
if (strncmp(de->d_name, "ttyf", 4) == 0 || strncmp(de->d_name, "plp", 3) == 0) {
|
||||
#else
|
||||
@ -777,7 +779,7 @@ static GList *add_serial_names(void)
|
||||
if (glist)
|
||||
g_list_sort(glist, gl_str_cmp);
|
||||
else
|
||||
glist = g_list_append(glist, GetString(STR_NONE_LAB));
|
||||
glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB));
|
||||
return glist;
|
||||
}
|
||||
|
||||
@ -797,10 +799,12 @@ static GList *add_ether_names(void)
|
||||
struct ifreq req, *ifr = ifc.ifc_req;
|
||||
for (int i=0; i<ifc.ifc_len; i+=sizeof(ifreq), ifr++) {
|
||||
req = *ifr;
|
||||
#if defined(__FreeBSD__) || defined(sgi)
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(sgi)
|
||||
if (ioctl(s, SIOCGIFADDR, &req) == 0 && (req.ifr_addr.sa_family == ARPHRD_ETHER || req.ifr_addr.sa_family == ARPHRD_ETHER+1)) {
|
||||
#else
|
||||
#elif defined(__linux__)
|
||||
if (ioctl(s, SIOCGIFHWADDR, &req) == 0 && req.ifr_hwaddr.sa_family == ARPHRD_ETHER) {
|
||||
#else
|
||||
if (false) {
|
||||
#endif
|
||||
char *str = new char[64];
|
||||
strncpy(str, ifr->ifr_name, 63);
|
||||
@ -813,7 +817,7 @@ static GList *add_ether_names(void)
|
||||
if (glist)
|
||||
g_list_sort(glist, gl_str_cmp);
|
||||
else
|
||||
glist = g_list_append(glist, GetString(STR_NONE_LAB));
|
||||
glist = g_list_append(glist, (void *)GetString(STR_NONE_LAB));
|
||||
return glist;
|
||||
}
|
||||
|
||||
@ -910,7 +914,7 @@ static void read_memory_settings(void)
|
||||
// Create "Memory/Misc" pane
|
||||
static void create_memory_pane(GtkWidget *top)
|
||||
{
|
||||
GtkWidget *box, *vbox, *hbox, *hbox2, *label, *scale, *opt, *menu;
|
||||
GtkWidget *box, *vbox, *hbox, *hbox2, *label, *scale, *menu;
|
||||
|
||||
box = make_pane(top, STR_MEMORY_MISC_PANE_TITLE);
|
||||
|
||||
|
@ -181,13 +181,13 @@ int16 XSERDPort::Open(uint16 config)
|
||||
if (fd < 0)
|
||||
goto open_error;
|
||||
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__)
|
||||
// Parallel port?
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) == 0)
|
||||
if (S_ISCHR(st.st_mode))
|
||||
is_parallel = (MAJOR(st.st_rdev) == LP_MAJOR);
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
// Parallel port?
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) == 0)
|
||||
|
@ -46,7 +46,7 @@ static int _llseek(uint fd, ulong hi, ulong lo, loff_t *res, uint wh)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
#include <sys/cdio.h>
|
||||
#endif
|
||||
|
||||
@ -121,6 +121,9 @@ void SysAddFloppyPrefs(void)
|
||||
#if defined(__linux__)
|
||||
PrefsAddString("floppy", "/dev/fd0H1440");
|
||||
PrefsAddString("floppy", "/dev/fd1H1440");
|
||||
#elif defined(__NetBSD__)
|
||||
PrefsAddString("floppy", "/dev/fd0a");
|
||||
PrefsAddString("floppy", "/dev/fd1a");
|
||||
#else
|
||||
PrefsAddString("floppy", "/dev/fd0");
|
||||
PrefsAddString("floppy", "/dev/fd1");
|
||||
@ -148,10 +151,11 @@ void SysAddDiskPrefs(void)
|
||||
|
||||
// Parse line
|
||||
char *dev, *mnt_point, *fstype;
|
||||
if (sscanf(line, "%s %s %s", &dev, &mnt_point, &fstype) == 3) {
|
||||
if (sscanf(line, "%as %as %as", &dev, &mnt_point, &fstype) == 3) {
|
||||
if (strcmp(fstype, "hfs") == 0)
|
||||
PrefsAddString("disk", dev);
|
||||
}
|
||||
free(dev); free(mnt_point); free(fstype);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
@ -174,6 +178,8 @@ void SysAddCDROMPrefs(void)
|
||||
PrefsAddString("cdrom", "/dev/cdrom");
|
||||
#elif defined(__FreeBSD__)
|
||||
PrefsAddString("cdrom", "/dev/cd0c");
|
||||
#elif defined(__NetBSD__)
|
||||
PrefsAddString("cdrom", "/dev/cd0d");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -190,6 +196,9 @@ void SysAddSerialPrefs(void)
|
||||
#elif defined(__FreeBSD__)
|
||||
PrefsAddString("seriala", "/dev/cuaa0");
|
||||
PrefsAddString("serialb", "/dev/cuaa1");
|
||||
#elif defined(__NetBSD__)
|
||||
PrefsAddString("seriala", "/dev/tty00");
|
||||
PrefsAddString("serialb", "/dev/tty01");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -214,8 +223,9 @@ static bool is_drive_mounted(const char *dev_name, char *mount_name)
|
||||
// Parse line
|
||||
if (strncmp(line, dev_name, strlen(dev_name)) == 0) {
|
||||
mount_name[0] = 0;
|
||||
char dummy[256];
|
||||
sscanf(line, "%s %s", dummy, mount_name);
|
||||
char *dummy;
|
||||
sscanf(line, "%as %s", &dummy, mount_name);
|
||||
free(dummy);
|
||||
fclose(f);
|
||||
return true;
|
||||
}
|
||||
@ -234,7 +244,7 @@ static bool is_drive_mounted(const char *dev_name, char *mount_name)
|
||||
void *Sys_open(const char *name, bool read_only)
|
||||
{
|
||||
bool is_file = strncmp(name, "/dev/", 5) != 0;
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__)
|
||||
// SCSI IDE
|
||||
bool is_cdrom = strncmp(name, "/dev/cd", 7) == 0 || strncmp(name, "/dev/acd", 8) == 0;
|
||||
#else
|
||||
@ -262,7 +272,7 @@ void *Sys_open(const char *name, bool read_only)
|
||||
}
|
||||
|
||||
// Open file/device
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__)
|
||||
int fd = open(name, (read_only ? O_RDONLY : O_RDWR) | (is_cdrom ? O_NONBLOCK : 0));
|
||||
#else
|
||||
int fd = open(name, read_only ? O_RDONLY : O_RDWR);
|
||||
@ -284,7 +294,7 @@ void *Sys_open(const char *name, bool read_only)
|
||||
if (fh->is_file) {
|
||||
// Detect disk image file layout
|
||||
loff_t size = 0;
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__)
|
||||
_llseek(fh->fd, 0, 0, &size, SEEK_END);
|
||||
#else
|
||||
size = lseek(fd, 0, SEEK_END);
|
||||
@ -309,7 +319,7 @@ void *Sys_open(const char *name, bool read_only)
|
||||
#else
|
||||
fh->cdrom_cap = 0;
|
||||
#endif
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
fh->is_floppy = ((st.st_rdev >> 16) == 2);
|
||||
#ifdef CDIOCCAPABILITY
|
||||
if (is_cdrom) {
|
||||
@ -362,7 +372,7 @@ size_t Sys_read(void *arg, void *buffer, loff_t offset, size_t length)
|
||||
return 0;
|
||||
|
||||
// Seek to position
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__)
|
||||
loff_t pos = offset + fh->start_byte, res;
|
||||
if (_llseek(fh->fd, pos >> 32, pos, &res, SEEK_SET) < 0)
|
||||
return 0;
|
||||
@ -388,7 +398,7 @@ size_t Sys_write(void *arg, void *buffer, loff_t offset, size_t length)
|
||||
return 0;
|
||||
|
||||
// Seek to position
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__)
|
||||
loff_t pos = offset + fh->start_byte, res;
|
||||
if (_llseek(fh->fd, pos >> 32, pos, &res, SEEK_SET) < 0)
|
||||
return 0;
|
||||
@ -415,7 +425,7 @@ loff_t SysGetFileSize(void *arg)
|
||||
if (fh->is_file)
|
||||
return fh->file_size;
|
||||
else {
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__)
|
||||
loff_t pos = 0;
|
||||
_llseek(fh->fd, 0, 0, &pos, SEEK_END);
|
||||
return pos - fh->start_byte;
|
||||
@ -446,7 +456,7 @@ void SysEject(void *arg)
|
||||
close(fh->fd); // Close and reopen so the driver will see the media change
|
||||
fh->fd = open(fh->name, O_RDONLY | O_NONBLOCK);
|
||||
}
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
if (fh->is_floppy) {
|
||||
fsync(fh->fd);
|
||||
//ioctl(fh->fd, FDFLUSH);
|
||||
@ -485,7 +495,7 @@ bool SysIsReadOnly(void *arg)
|
||||
if (!fh)
|
||||
return true;
|
||||
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__)
|
||||
if (fh->is_floppy) {
|
||||
struct floppy_drive_struct stat;
|
||||
ioctl(fh->fd, FDGETDRVSTAT, &stat);
|
||||
@ -541,7 +551,7 @@ bool SysIsDiskInserted(void *arg)
|
||||
#endif
|
||||
cdrom_tochdr header;
|
||||
return ioctl(fh->fd, CDROMREADTOCHDR, &header) == 0;
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
} else if (fh->is_floppy) {
|
||||
return false; //!!
|
||||
} else if (fh->is_cdrom) {
|
||||
@ -645,7 +655,7 @@ bool SysCDReadTOC(void *arg, uint8 *toc)
|
||||
*toc++ = toc_size >> 8;
|
||||
*toc++ = toc_size & 0xff;
|
||||
return true;
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
uint8 *p = toc + 2;
|
||||
|
||||
// Header
|
||||
@ -730,7 +740,7 @@ bool SysCDGetPosition(void *arg, uint8 *pos)
|
||||
*pos++ = chan.cdsc_reladdr.msf.second;
|
||||
*pos++ = chan.cdsc_reladdr.msf.frame;
|
||||
return true;
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
struct ioc_read_subchannel chan;
|
||||
chan.data_format = CD_MSF_FORMAT;
|
||||
chan.address_format = CD_MSF_FORMAT;
|
||||
@ -780,7 +790,7 @@ bool SysCDPlay(void *arg, uint8 start_m, uint8 start_s, uint8 start_f, uint8 end
|
||||
play.cdmsf_sec1 = end_s;
|
||||
play.cdmsf_frame1 = end_f;
|
||||
return ioctl(fh->fd, CDROMPLAYMSF, &play) == 0;
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
struct ioc_play_msf play;
|
||||
play.start_m = start_m;
|
||||
play.start_s = start_s;
|
||||
@ -808,7 +818,7 @@ bool SysCDPause(void *arg)
|
||||
if (fh->is_cdrom) {
|
||||
#if defined(__linux__)
|
||||
return ioctl(fh->fd, CDROMPAUSE) == 0;
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
return ioctl(fh->fd, CDIOCPAUSE) == 0;
|
||||
#endif
|
||||
} else
|
||||
@ -829,7 +839,7 @@ bool SysCDResume(void *arg)
|
||||
if (fh->is_cdrom) {
|
||||
#if defined(__linux__)
|
||||
return ioctl(fh->fd, CDROMRESUME) == 0;
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
return ioctl(fh->fd, CDIOCRESUME) == 0;
|
||||
#endif
|
||||
} else
|
||||
@ -850,7 +860,7 @@ bool SysCDStop(void *arg, uint8 lead_out_m, uint8 lead_out_s, uint8 lead_out_f)
|
||||
if (fh->is_cdrom) {
|
||||
#if defined(__linux__)
|
||||
return ioctl(fh->fd, CDROMSTOP) == 0;
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
return ioctl(fh->fd, CDIOCSTOP) == 0;
|
||||
#endif
|
||||
} else
|
||||
@ -889,7 +899,7 @@ void SysCDSetVolume(void *arg, uint8 left, uint8 right)
|
||||
vol.channel0 = vol.channel2 = left;
|
||||
vol.channel1 = vol.channel3 = right;
|
||||
ioctl(fh->fd, CDROMVOLCTRL, &vol);
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
struct ioc_vol vol;
|
||||
vol.vol[0] = vol.vol[2] = left;
|
||||
vol.vol[1] = vol.vol[3] = right;
|
||||
@ -916,7 +926,7 @@ void SysCDGetVolume(void *arg, uint8 &left, uint8 &right)
|
||||
ioctl(fh->fd, CDROMVOLREAD, &vol);
|
||||
left = vol.channel0;
|
||||
right = vol.channel1;
|
||||
#elif defined(__FreeBSD__)
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
struct ioc_vol vol;
|
||||
ioctl(fh->fd, CDIOCGETVOL, &vol);
|
||||
left = vol.vol[0];
|
||||
|
Loading…
x
Reference in New Issue
Block a user