FreeBSD Bugzilla – Attachment 129945 Details for
Bug 174017
emulators/snes9x: Update to 1.53
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 42.92 KB, created by
fiziologus
on 2012-11-30 16:50:00 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
fiziologus
Created:
2012-11-30 16:50:00 UTC
Size:
42.92 KB
patch
obsolete
>diff -ruN snes9x.orig/Makefile snes9x/Makefile >--- snes9x.orig/Makefile 2012-11-17 09:57:23.000000000 +0400 >+++ snes9x/Makefile 2012-11-30 18:40:57.000000000 +0400 >@@ -6,40 +6,40 @@ > # > > PORTNAME= snes9x >-PORTVERSION= 1.51 >-PORTREVISION= 4 >+PORTVERSION= 1.53 > CATEGORIES= emulators > MASTER_SITES= http://files.ipherswipsite.com/snes9x/ \ >- http://www.lysator.liu.se/snes9x/${PORTVERSION}/ >+ https://sites.google.com/site/bearoso/${PORTNAME}/ \ >+ http://www.s9x-w32.de/dl/ \ >+ http://snesemu.black-ship.net/emus/snes9x/ \ >+ http://camoy.sdf.org/mirror/snes9x/ \ >+ http://bigkidtennis.com/snes9x/ > DISTNAME= ${PORTNAME}-${PORTVERSION}-src > > MAINTAINER= acm@FreeBSD.org > COMMENT= Super Nintendo Entertainment System(SNES) Emulator > >-LIB_DEPENDS= png15:${PORTSDIR}/graphics/png >- > USE_BZIP2= yes > USE_XORG= x11 sm ice xext > USE_GMAKE= yes >+# Force GCC (clang freeze in filters/hq2x.cpp) >+USE_GCC= 4.2+ > GNU_CONFIGURE= yes >-CONFIGURE_ARGS+= --without-extensions > CPPFLAGS+= -I${LOCALBASE}/include > LDFLAGS+= -L${LOCALBASE}/lib >-MAKE_ARGS= INCLUDES="-I${WRKSRC}/unzip -I${WRKSRC} -I${LOCALBASE}/include \ >- ${PTHREAD_CFLAGS}" LDLIBS="-L${LOCALBASE}/lib ${PTHREAD_LIBS}" \ >- OPTIMISE="${CXXFLAGS}" > WRKSRC= ${WRKDIR}/${DISTNAME} >+CONFIGURE_WRKSRC= ${WRKSRC}/unix >+BUILD_WRKSRC= ${CONFIGURE_WRKSRC} > >-PLIST_FILES= bin/${PORTNAME} >+PLIST_FILES= bin/${PORTNAME} etc/${PORTNAME}/snes9x.conf > SUB_FILES= pkg-message > >-OPTIONS= DEBUG "Enable debug information" off \ >- OPENGL "Enable OpenGL support" off \ >- SCREENSHOT "Enable screenshot support" on \ >- X86_ASM "Use i386 optimization (only for i386)" on \ >- MMX "Enable MMX (only for i386)" off \ >- JMA "Enable JMA archive decompression support" on \ >- NETPLAY "Enable network support" on >+OPTIONS_DEFINE= DEBUG SCREENSHOT JMA NETPLAY >+OPTIONS_DEFAULT= SCREENSHOT JMA NETPLAY >+ >+SCREENSHOT_DESC= Enable screenshot support >+JMA_DESC= Enable screenshot support >+NETPLAY_DESC= Enable network support > > .include <bsd.port.pre.mk> > >@@ -49,65 +49,45 @@ > README > .endif > >-.if defined(WITH_DEBUG) >-CONFIGURE_ARGS+= --with-debug >+.if ${PORT_OPTIONS:MDEBUG} >+CONFIGURE_ARGS+= --enable-debug > .else >-CONFIGURE_ARGS+= --without-debug >+CONFIGURE_ARGS+= --disable-debug > .endif > >-.if ${ARCH} == "i386" >-.if !defined(WITHOUT_X86_ASM) >-BUILD_DEPENDS+= nasm:${PORTSDIR}/devel/nasm >-CONFIGURE_ARGS+= --with-assembler >-.else >-CONFIGURE_ARGS+= --without-assembler >-.endif >- >-.if defined(WITH_MMX) && !defined(PACKAGE_BUILDING) >-CONFIGURE_ARGS+= --with-mmx >-.else >-CONFIGURE_ARGS+= --without-mmx >-.endif >-.endif >- >-.if defined(WITH_OPENGL) >-USE_GL= yes >-CONFIGURE_ARGS+= --with-opengl >-SNES9X_BIN= osnes9x >-.else >-SNES9X_BIN= snes9x >-.endif >- >-.if !defined(WITHOUT_SCREENSHOT) >+.if ${PORT_OPTIONS:MSCREENSHOT} > LIB_DEPENDS+= png15:${PORTSDIR}/graphics/png >-CONFIGURE_ARGS+= --with-screenshot >+CONFIGURE_ARGS+= --enable-screenshot > .else >-CONFIGURE_ARGS+= --without-screenshot >+CONFIGURE_ARGS+= --disable-screenshot > .endif > >-.if !defined(WITHOUT_JMA) >-CONFIGURE_ARGS+= --with-jma-decomp >+.if ${PORT_OPTIONS:MJMA} >+CONFIGURE_ARGS+= --enable-jma > .else >-CONFIGURE_ARGS+= --without-jma-decomp >+CONFIGURE_ARGS+= --disable-jma > .endif > >-.if !defined(WITHOUT_NETPLAY) >-CONFIGURE_ARGS+= --with-netplay >+.if ${PORT_OPTIONS:MNETPLAY} >+CONFIGURE_ARGS+= --enable-netplay > .else >-CONFIGURE_ARGS+= --without-netplay >+CONFIGURE_ARGS+= --disable-netplay > .endif > > .if exists(/usr/lib/libusbhid.a) >-CONFIGURE_ARGS+= --with-joystick >+CONFIGURE_ARGS+= --enable-gamepad > .else >-CONFIGURE_ARGS+= --without-joystick >+CONFIGURE_ARGS+= --disable-gamepad > .endif > > post-patch: >- @${REINPLACE_CMD} -i "" -e 's|Pitch2|Pitch|g' ${WRKSRC}/unix/opengl.cpp >+ ${REINPLACE_CMD} -e "s|linux|freebsd|g" \ >+ -e "s|lpng|lpng15|g" ${WRKSRC}/unix/configure >+ ${REINPLACE_CMD} -e 's|-DMITSHM||' ${WRKSRC}/unix/Makefile.in >+ ${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|" ${WRKSRC}/port.h > > do-install: >-.if !defined(NOPORTDOCS) >+.if ${PORT_OPTIONS:MDOCS} > ${MKDIR} ${DOCSDIR} > .for FILE in control* changes.txt hardware.txt porting.html faqs.txt \ > snapshots.txt snes9x.conf.default >@@ -115,7 +95,9 @@ > .endfor > ${INSTALL_DATA} ${WRKSRC}/unix/docs/readme_unix.txt ${DOCSDIR}/README > .endif >- ${INSTALL_PROGRAM} ${WRKSRC}/${SNES9X_BIN} ${PREFIX}/bin/${PORTNAME} >+ ${INSTALL_PROGRAM} ${BUILD_WRKSRC}/snes9x ${PREFIX}/bin/${PORTNAME} >+ ${MKDIR} ${PREFIX}/etc/${PORTNAME} >+ ${INSTALL_PROGRAM} ${WRKSRC}/doc/snes9x.conf.default ${PREFIX}/etc/${PORTNAME}/snes9x.conf > > post-install: > @${CAT} ${PKGMESSAGE} >diff -ruN snes9x.orig/distinfo snes9x/distinfo >--- snes9x.orig/distinfo 2011-07-02 21:14:16.000000000 +0400 >+++ snes9x/distinfo 2012-11-29 21:43:04.000000000 +0400 >@@ -1,2 +1,2 @@ >-SHA256 (snes9x-1.51-src.tar.bz2) = 70c8f41fc7f1e000605127e0f4261e3eb52c72019b3cbf9bc8061b0b8ccdf687 >-SIZE (snes9x-1.51-src.tar.bz2) = 1707256 >+SHA256 (snes9x-1.53-src.tar.bz2) = 9f7c5d2d0fa3fe753611cf94e8879b73b8bb3c0eab97cdbcb6ab7376efa78dc3 >+SIZE (snes9x-1.53-src.tar.bz2) = 1838746 >diff -ruN snes9x.orig/files/patch-2XSAI.CPP snes9x/files/patch-2XSAI.CPP >--- snes9x.orig/files/patch-2XSAI.CPP 2004-05-30 03:59:56.000000000 +0400 >+++ snes9x/files/patch-2XSAI.CPP 1970-01-01 03:00:00.000000000 +0300 >@@ -1,12 +0,0 @@ >---- 2xsai.cpp.orig Fri Dec 5 02:03:08 2003 >-+++ 2xsai.cpp Sun Jan 25 01:41:08 2004 >-@@ -81,7 +81,8 @@ >- #include "port.h" >- #include "gfx.h" >- >--#if (defined(USE_X86_ASM) && (defined (__i386__) || defined (__i486__) || \ >-+#if (defined(USE_X86_ASM) && defined(ASMKREED) && \ >-+ (defined (__i386__) || defined (__i486__) || \ >- defined (__i586__) || defined (__WIN32__) || defined (__DJGPP))) >- # ifndef MMX >- # define MMX >diff -ruN snes9x.orig/files/patch-3d.h snes9x/files/patch-3d.h >--- snes9x.orig/files/patch-3d.h 2003-10-20 08:20:31.000000000 +0400 >+++ snes9x/files/patch-3d.h 1970-01-01 03:00:00.000000000 +0300 >@@ -1,11 +0,0 @@ >---- 3d.h.orig Wed Aug 13 06:27:16 2003 >-+++ 3d.h Fri Sep 12 00:05:49 2003 >-@@ -80,7 +80,7 @@ >- #include <GL/gl.h> >- #include <GL/glu.h> >- >--#ifdef __linux__ >-+#if defined(__linux__) || defined(__FreeBSD__) >- #include <GL/glx.h> >- #endif >- >diff -ruN snes9x.orig/files/patch-Makefile.in snes9x/files/patch-Makefile.in >--- snes9x.orig/files/patch-Makefile.in 2006-12-27 20:27:37.000000000 +0300 >+++ snes9x/files/patch-Makefile.in 1970-01-01 03:00:00.000000000 +0300 >@@ -1,19 +0,0 @@ >---- Makefile.in Tue Dec 26 16:46:56 2006 >-+++ Makefile.in Tue Dec 26 16:49:20 2006 >-@@ -138,7 +138,6 @@ >- >- ifdef THREAD_SOUND >- CPUDEFINES += -DUSE_THREADS >--EXTRALIBS += -lpthread >- endif >- >- ifdef GLIDE >-@@ -150,7 +149,7 @@ >- ifdef OPENGL >- OPENGLOBJS = unix/opengl.o >- OPENGLDEFINES = -DUSE_OPENGL >--OPENGLLIBS = -lGL -lGLU -ldl >-+OPENGLLIBS = -lGL -lGLU >- endif >- >- ifdef AIDO >diff -ruN snes9x.orig/files/patch-ad snes9x/files/patch-ad >--- snes9x.orig/files/patch-ad 2007-10-04 09:43:03.000000000 +0400 >+++ snes9x/files/patch-ad 1970-01-01 03:00:00.000000000 +0300 >@@ -1,29 +0,0 @@ >---- memmap.cpp 2007-10-03 11:11:07.000000000 -0500 >-+++ memmap.cpp 2007-10-03 11:11:34.000000000 -0500 >-@@ -169,7 +169,7 @@ >- #include <ctype.h> >- #include <assert.h> >- >--#ifdef __linux >-+#if defined(__linux) || defined(__FreeBSD__) >- #include <unistd.h> >- #endif >- >-@@ -1473,7 +1473,7 @@ >- { >- fwrite((char *) Multi.sramB, size, 1, file); >- fclose(file); >--#ifdef __linux >-+#if defined(__linux) || defined(__FreeBSD__) >- chown(name, getuid(), getgid()); >- #endif >- } >-@@ -1502,7 +1502,7 @@ >- { >- fwrite((char *) SRAM, size, 1, file); >- fclose(file); >--#ifdef __linux >-+#if defined(__linux) || defined(__FreeBSD__) >- chown(sramName, getuid(), getgid()); >- #endif >- if (Settings.SPC7110RTC) >diff -ruN snes9x.orig/files/patch-ae snes9x/files/patch-ae >--- snes9x.orig/files/patch-ae 2006-12-27 20:27:37.000000000 +0300 >+++ snes9x/files/patch-ae 1970-01-01 03:00:00.000000000 +0300 >@@ -1,13 +0,0 @@ >---- port.h.orig Fri Jun 30 08:40:56 2006 >-+++ port.h Tue Dec 26 23:09:22 2006 >-@@ -360,6 +360,10 @@ >- #define SYS_CONFIG_FILE "/etc/snes9x/snes9x.conf" >- #endif >- >-+#ifdef __FreeBSD__ >-+#define TITLE "Snes9X: FreeBSD" >-+#endif >-+ >- #ifndef TITLE >- #define TITLE "Snes9x" >- #endif >diff -ruN snes9x.orig/files/patch-af snes9x/files/patch-af >--- snes9x.orig/files/patch-af 2007-10-04 09:43:03.000000000 +0400 >+++ snes9x/files/patch-af 1970-01-01 03:00:00.000000000 +0300 >@@ -1,455 +0,0 @@ >---- unix/unix.cpp 2007-04-28 19:51:08.000000000 -0500 >-+++ unix/unix.cpp 2007-10-03 16:53:16.000000000 -0500 >-@@ -173,7 +173,7 @@ >- #include <fcntl.h> >- #include <sys/time.h> >- /* FIXME: Linux alpha (aristocat) has a broken timercmp. Make testcase */ >--#if defined(__linux) >-+#if defined(__linux) || defined(__FreeBSD__) >- # ifndef timercmp >- # define timercmp(tvp, uvp, cmp)\ >- ((tvp)->tv_sec cmp (uvp)->tv_sec ||\ >-@@ -197,7 +197,7 @@ >- pthread_mutex_t mutex; >- #endif >- >--#if !defined(NOSOUND) && defined(__linux) >-+#if !defined(NOSOUND) && (defined(__linux) || defined(__FreeBSD__)) >- #include <sys/soundcard.h> >- #include <sys/mman.h> >- #endif >-@@ -210,6 +210,11 @@ >- #endif >- #endif >- >-+#if defined(__FreeBSD__) >-+typedef sig_t SIG_PF; >-+#include <err.h> >-+#endif >-+ >- //Breaks sol9 and probably others. >- //#if defined(__sun) && defined(__GNUC__) >- //typedef void (*SIG_PF)(); >-@@ -233,11 +238,12 @@ >- >- #ifdef NETPLAY_SUPPORT >- #include "netplay.h" >-- >- #ifdef _DEBUG >- #define NP_DEBUG 2 >- #endif >-+#endif >- >-+#if defined(NETPLAY_SUPPORT) || defined(JOYSTICK_SUPPORT) >- /* accessors into controls.cpp static variables */ >- uint16 MovieGetJoypad(int i); >- void MovieSetJoypad(int i, uint16 buttons); >-@@ -245,22 +251,86 @@ >- /* Joypads status information */ >- uint32 old_joypads[8]; >- uint32 joypads[8]; >-- >- #endif >- >- #ifdef JOYSTICK_SUPPORT >-+#define JOYSTICK_MAX_DEVICES 4 >-+int JoystickShift = 0; >-+uint8 js_mod [8] = {0, 0, 0, 0, 0, 0, 0, 0}; >- #if defined(__linux) >-+#define JOYSTICK_MAX_BUTTONS 4 >- #include <linux/joystick.h> >--uint8 js_mod [8] = {0, 0, 0, 0, 0, 0, 0, 0}; >- int js_fd [8] = {-1, -1, -1, -1, -1, -1, -1, -1}; >- char *js_device [8] = {"/dev/js0", "/dev/js1", "/dev/js2", "/dev/js3", "/dev/js4", "/dev/js5", "/dev/js6", "/dev/js7" }; >- #endif >- >-+#if defined(__FreeBSD__) >-+#include <sys/types.h> >-+#include <sys/param.h> >-+ >-+extern "C" { >-+#define class klass >-+#include <dev/usb/usb.h> >-+#include <dev/usb/usbhid.h> >-+#undef class >-+ >-+#if __FreeBSD_version < 500111 >-+#include <libusbhid.h> >-+#else >-+#include <usbhid.h> >-+#endif >-+} >-+ >-+#define JOYSTICK_MAX_BUTTONS 16 >-+ >-+#define JOYSTICK_MAP_BUTTON_INITIALIZER \ >-+ { \ >-+ SNES_Y_MASK, SNES_B_MASK, SNES_A_MASK, \ >-+ SNES_X_MASK, SNES_TL_MASK, SNES_TR_MASK, \ >-+ SNES_TL_MASK, SNES_TR_MASK, \ >-+ SNES_SELECT_MASK, SNES_START_MASK, 0, 0, 0, 0, 0, 0 \ >-+ } >-+ >-+int js_map_button[JOYSTICK_MAX_BUTTONS][16] = { >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER, >-+ JOYSTICK_MAP_BUTTON_INITIALIZER >-+}; >-+char *js_device [4] = {"/dev/uhid0", "/dev/uhid1", "/dev/uhid2", "/dev/uhid3"}; >-+struct js_range { >-+ int min, max, lower_third, higher_third; >-+}; >-+struct js_info { >-+ char *buf; >-+ int reportlen; >-+ int offset; >-+ struct js_range x, y; >-+ int buttons; >-+ struct hid_item *hids; >-+ int fd; >-+ int joy; >-+} js_info[4]; >-+int js_count = 0; >-+#endif >-+ >- void InitJoysticks (); >- void ReadJoysticks (); >- #endif >- >--#if !defined(NOSOUND) && defined (__linux) >-+#if !defined(NOSOUND) && (defined (__linux) || defined(__FreeBSD__)) >- #define CONFIGURABLE_SOUND_DEVICE >- char *sound_device = "/dev/dsp"; >- #endif >-@@ -285,7 +355,7 @@ >- const char *inc_format="%03d"; >- >- //FIXME: I see no reason not to configureenable this for all Unixen >--#if defined(DEBUGGER) && (defined(__linux) || defined(__sun)) >-+#if defined(DEBUGGER) && (defined(__linux) || defined(__sun) || defined(__FreeBSD__)) >- static void sigbrkhandler(int) >- { >- CPU.Flags |= DEBUG_MODE_FLAG; >-@@ -326,22 +396,54 @@ >- >- void S9xParseArg (char **argv, int &i, int argc) >- { >-+#ifdef JOYSTICK_SUPPORT >- if (strcmp (argv [i], "-j") == 0 || >- strcasecmp (argv [i], "-nojoy") == 0) { >--#ifdef JOYSTICK_SUPPORT >- Settings.JoystickEnabled = FALSE; >-+ } >-+ >-+#ifdef __FreeBSD__ >-+ else if (strcasecmp(argv[i], "-joyshift") == 0) >-+ JoystickShift = 1; >-+#endif >-+ else if (strncasecmp(argv[i], "-joydev", sizeof("-joydev") - 1) == 0) { >-+ char *end, *snum = argv[i] + sizeof("-joydev") - 1; >-+ unsigned long num; >-+ >-+ if (*snum == '\0' || argc < i + 1) >-+ S9xUsage(); >-+ if ((num = strtoul(snum, &end, 10)) < JOYSTICK_MAX_DEVICES && >-+ num > 0 && *end == '\0') >-+ js_device[num - 1] = argv[++i]; >-+ else >-+ S9xUsage (); >-+ } >-+ else if (strncasecmp(argv[i], "-joymap", sizeof("-joymap") - 1) == 0) { >-+ static const int button_masks[] = { >-+ SNES_A_MASK, SNES_B_MASK, SNES_X_MASK, SNES_Y_MASK, >-+ SNES_TL_MASK, SNES_TR_MASK, SNES_START_MASK, SNES_SELECT_MASK >-+ }; >-+ char *end, *snum = argv[i] + sizeof("-joymap") - 1; >-+ unsigned long num; >-+ int *js_buttons, b; >-+ >-+ if (argc < i + (sizeof(button_masks) / sizeof(int)) || *snum == '\0') >-+ S9xUsage(); >-+ num = strtoul(snum, &end, 10); >-+ if (*end != '\0') >-+ S9xUsage(); >-+ if (num == 0 || num > 4) /* hardcode: max joysticks */ >-+ S9xUsage(); >-+ js_buttons = js_map_button[num - 1]; >-+ for (b = 0; b < (sizeof(button_masks) / sizeof(int)); b++) >-+ if ((num = strtoul(argv[++i], &end, 10)) <= 16 && num != 0 && >-+ *end == '\0') >-+ js_buttons[num - 1] = button_masks[b]; >-+ } >-+ >-+ else >- #endif >-- } else if (strncasecmp (argv [i], "-joydev", 7) == 0 && argv[i][7]>='1' && argv[i][7]<='8' && argv[i][8]=='\0') >-- { >-- int j = argv[i][7]-'1'; >-- if (i + 1 < argc) { >--#ifdef JOYSTICK_SUPPORT >-- js_device[j] = argv[++i]; >--#else >-- S9xMessage(S9X_WARNING, S9X_USAGE, "Joystick support is not available!"); >--#endif >-- } else S9xUsage (); >-- } else if (strcasecmp (argv [i], "-sounddev") == 0) { >-+ if (strcasecmp (argv [i], "-sounddev") == 0) { >- if (i + 1 < argc) { >- #if defined(CONFIGURABLE_SOUND_DEVICE) >- sound_device = argv[++i]; >-@@ -552,7 +654,7 @@ >- #if !defined(__MSDOS) && defined(DEBUGGER) >- #if defined(__unix) && !defined(__NeXT__) >- struct sigaction sa; >--#if defined(__linux) >-+#if defined(__linux) || defined(__FreeBSD__) >- sa.sa_handler = sigbrkhandler; >- #else >- sa.sa_handler = (SIG_PF) sigbrkhandler; >-@@ -770,6 +872,7 @@ >- } >- >- #ifdef JOYSTICK_SUPPORT >-+#ifdef __linux >- void InitJoysticks () >- { >- #ifdef JSIOCGVERSION >-@@ -854,6 +957,189 @@ >- } >- #endif >- } >-+#endif >-+#if defined(__FreeBSD__) >-+ >-+/* >-+ * USB HID code for FreeBSD/NetBSD >-+ * Brian Feldman <green@FreeBSD.org> >-+ * >-+ * Reference used: >-+ * X-Mame USB HID joystick driver for NetBSD. >-+ * >-+ * Written by Krister Walfridsson <cato@df.lth.se> >-+ */ >-+ >-+int >-+InitJoystickFd(int fd, char *dev) { >-+ report_desc_t rd; >-+ struct hid_data *d; >-+ struct hid_item h, new_h; >-+ struct js_info *my_info; >-+ int reportlen, report_id, is_joystick; >-+ >-+ my_info = &js_info[js_count]; >-+ rd = hid_get_report_desc(fd); >-+ if (rd == 0) { >-+ warn("%s", dev); >-+ return (-1); >-+ } >-+ report_id = 0; >-+#if __FreeBSD_version < 500111 >-+ reportlen = hid_report_size(rd, report_id, hid_input); >-+#else >-+ reportlen = hid_report_size(rd, hid_input, report_id); >-+#endif >-+ my_info->buf = (char *)malloc(reportlen); >-+ if (my_info->buf == NULL) >-+ err(1, "malloc"); >-+ my_info->reportlen = reportlen; >-+ my_info->offset = report_id != 0; >-+ my_info->buttons = 0; >-+ my_info->hids = NULL; >-+ >-+ is_joystick = 0; >-+#if __FreeBSD_version < 500111 >-+ for (d = hid_start_parse(rd, 1 << hid_input); >-+#else >-+ for (d = hid_start_parse(rd, 1 << hid_input, report_id); >-+#endif >-+ hid_get_item(d, &h);) { >-+ int usage, page, link_it = 0; >-+ struct js_range *axis; >-+ >-+ page = HID_PAGE(h.usage); >-+ usage = HID_USAGE(h.usage); >-+ if (!is_joystick) >-+ is_joystick = (h.kind == hid_collection && >-+ page == HUP_GENERIC_DESKTOP && >-+ (usage == HUG_JOYSTICK || usage == HUG_GAME_PAD)); >-+ if (h.kind != hid_input || !is_joystick) >-+ continue; >-+ axis = NULL; >-+ if (page == HUP_GENERIC_DESKTOP) { >-+ switch (usage) { >-+ case HUG_X: >-+ case HUG_RX: >-+ axis = &my_info->x; >-+ break; >-+ case HUG_Y: >-+ case HUG_RY: >-+ axis = &my_info->y; >-+ break; >-+ } >-+ } >-+ if (axis != NULL) { >-+ axis->min = h.logical_minimum; >-+ axis->max = h.logical_maximum; >-+ axis->lower_third = axis->min + >-+ (axis->max - axis->min) / 3; >-+ axis->higher_third = axis->min + >-+ (axis->max - axis->min) * 2 / 3; >-+ link_it = 1; >-+ } >-+ if (!link_it) { >-+ if (page != HUP_BUTTON || usage > 16) >-+ continue; >-+ if (usage > my_info->buttons) >-+ my_info->buttons = usage; >-+ } >-+ new_h = h; >-+ new_h.next = my_info->hids; >-+ my_info->hids = (struct hid_item *) >-+ malloc(sizeof(*my_info->hids)); >-+ if (my_info->hids == NULL) >-+ err(1, "malloc"); >-+ *my_info->hids = new_h; >-+ } >-+ printf("Joystick %s: %d buttons, X range %d - %d, Y range %d - %d\n", >-+ dev, my_info->buttons, my_info->x.min, my_info->x.max, >-+ my_info->y.min, my_info->y.max); >-+ my_info->fd = fd; >-+ if (JoystickShift) { >-+ my_info->joy = js_count + 1; >-+ } else >-+ my_info->joy = js_count; >-+ return (0); >-+} >-+ >-+void >-+InitJoysticks() { >-+ int i, fd; >-+ >-+ for (i = 0; i < (sizeof(js_device) / sizeof(js_device[0])); i++) { >-+ fd = open(js_device[i], O_RDONLY | O_NONBLOCK); >-+ if (fd == -1) >-+ continue; >-+ if (InitJoystickFd(fd, js_device[i]) == 0) >-+ js_count++; >-+ else >-+ close(fd); >-+ } >-+} >-+ >-+void >-+ReadJoysticks() { >-+ struct hid_item *h; >-+ int page, usage, njoy, joy; >-+ >-+ for (njoy = 0; njoy < js_count; njoy++) { >-+ struct js_info *jsi; >-+ >-+ jsi = &js_info[njoy]; >-+ joy = jsi->joy; >-+ >-+ if (read(jsi->fd, jsi->buf, jsi->reportlen) != jsi->reportlen) >-+ continue; >-+ for (h = jsi->hids; h != NULL; h = h->next) { >-+ int d; >-+ >-+ d = hid_get_data(jsi->buf + jsi->offset, h); >-+ page = HID_PAGE(h->usage); >-+ usage = HID_USAGE(h->usage); >-+ >-+ switch (page) { >-+ case HUP_GENERIC_DESKTOP: >-+ switch (usage) { >-+ case HUG_X: >-+ case HUG_RX: >-+ if (d < jsi->x.lower_third) { >-+ joypads[joy] |= SNES_LEFT_MASK; >-+ joypads[joy] &= ~SNES_RIGHT_MASK; >-+ } else if (d < jsi->x.higher_third) { >-+ joypads[joy] &= ~SNES_LEFT_MASK; >-+ joypads[joy] &= ~SNES_RIGHT_MASK; >-+ } else { >-+ joypads[joy] &= ~SNES_LEFT_MASK; >-+ joypads[joy] |= SNES_RIGHT_MASK; >-+ } >-+ break; >-+ case HUG_Y: >-+ case HUG_RY: >-+ if (d < jsi->y.lower_third) { >-+ joypads[joy] |= SNES_UP_MASK; >-+ joypads[joy] &= ~SNES_DOWN_MASK; >-+ } else if (d < jsi->y.higher_third) { >-+ joypads[joy] &= ~SNES_UP_MASK; >-+ joypads[joy] &= ~SNES_DOWN_MASK; >-+ } else { >-+ joypads[joy] &= ~SNES_UP_MASK; >-+ joypads[joy] |= SNES_DOWN_MASK; >-+ } >-+ break; >-+ } >-+ break; >-+ case HUP_BUTTON: >-+ if (d) >-+ joypads[joy] |= js_map_button[njoy][usage - 1]; >-+ else >-+ joypads[joy] &= ~js_map_button[njoy][usage - 1]; >-+ break; >-+ } >-+ } >-+ } >-+} >-+#endif // defined(__FreeBSD__) >- #endif // defined (JOYSTICK_SUPPORT) >- >- START_EXTERN_C >-@@ -1716,7 +2002,7 @@ >- } >- #endif >- >--#if !defined(NOSOUND) && defined(__linux) >-+#if !defined(NOSOUND) && (defined(__linux) || defined(__FreeBSD__)) >- static int Rates[8] = >- { >- 0, 8000, 11025, 16000, 22050, 32000, 44100, 48000 >-@@ -1847,7 +2133,7 @@ >- #endif >- >- >--#if !defined(NOSOUND) && (defined (__linux) || defined (__sun)) >-+#if !defined(NOSOUND) && (defined (__linux) || defined (__sun) || defined(__FreeBSD__)) >- void S9xUnixProcessSound (void) >- { >- } >-@@ -1890,7 +2176,7 @@ >- } >- #endif >- >--#if !defined(NOSOUND) && (defined (__linux) || defined (__sun)) >-+#if !defined(NOSOUND) && (defined (__linux) || defined (__sun) || defined(__FreeBSD__)) >- void S9xGenerateSound () >- { >- /* Linux and Sun versions */ >-@@ -1985,7 +2271,7 @@ >- /* If not, this will be called by timer */ >- if (Settings.Mute) >- return NULL; >--#ifdef __linux >-+#if defined(__linux) || defined(__FreeBSD__) >- audio_buf_info info; >- >- if (!Settings.ThreadSound && >diff -ruN snes9x.orig/files/patch-ag snes9x/files/patch-ag >--- snes9x.orig/files/patch-ag 1999-12-29 10:12:58.000000000 +0300 >+++ snes9x/files/patch-ag 1970-01-01 03:00:00.000000000 +0300 >@@ -1,32 +0,0 @@ >-diff -ru ../../work/release/unix/xf86.cpp ./unix/xf86.cpp >---- ../../work/release/unix/xf86.cpp Tue Sep 22 06:36:50 1998 >-+++ ./unix/xf86.cpp Wed Dec 29 01:54:04 1999 >-@@ -4,16 +4,20 @@ >- Question/comments regarding this file only: maciej@imsa.edu >- */ >- >--#ifdef __linux >-+#if defined(__linux) || defined(__FreeBSD__) >- //#define USE_XF86VIDMODE >- >-+#ifdef __linux >- #include <asm/ioctls.h> >-+#endif >-+#include <sys/types.h> >- #include <sys/ioctl.h> >- #include <sys/time.h> >-+#ifdef __linux >- #include <linux/ioctl.h> >-+#endif >- >- #include <fcntl.h> >--#include <sys/types.h> >- >- #include <string.h> >- #include <ctype.h> >-@@ -833,4 +837,4 @@ >- ret = 1; >- return (ret); >- } >--#endif /* __linux */ >-+#endif /* __linux || __FreeBSD__ */ >diff -ruN snes9x.orig/files/patch-ah snes9x/files/patch-ah >--- snes9x.orig/files/patch-ah 2007-10-04 09:43:04.000000000 +0400 >+++ snes9x/files/patch-ah 1970-01-01 03:00:00.000000000 +0300 >@@ -1,24 +0,0 @@ >---- unzip/unzip.h 2007-10-03 12:28:47.000000000 -0500 >-+++ unzip/unzip.h 2007-10-03 12:30:22.000000000 -0500 >-@@ -41,14 +41,18 @@ >- #ifndef _unz_H >- #define _unz_H >- >--#ifdef __cplusplus >--extern "C" { >--#endif >-+#include <sys/types.h> >- >- #ifndef _ZLIB_H >- #include <zlib.h> >- #endif >- >-+#ifdef __cplusplus >-+extern "C" { >-+#endif >-+ >-+#define ZEXPORT >-+ >- #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) >- /* like the STRICT of WIN32, we define a pointer that cannot be converted >- from (void*) without cast */ >diff -ruN snes9x.orig/files/patch-configure snes9x/files/patch-configure >--- snes9x.orig/files/patch-configure 2007-10-04 09:43:04.000000000 +0400 >+++ snes9x/files/patch-configure 1970-01-01 03:00:00.000000000 +0300 >@@ -1,124 +0,0 @@ >---- configure.orig 2007-04-29 16:03:52.000000000 -0500 >-+++ configure 2007-10-03 14:33:44.000000000 -0500 >-@@ -860,6 +860,7 @@ >- --with(out)-opengl Use OpenGL for output (default: without) >- --with(out)-aido Use a shared memory area for output (default: without) >- --with(out)-assembler Use assembler cores if available (default: with) >-+ --with(out)-mmx Use assembler cores if available (default: with) >- --with(out)-zsnesc4 Use ZSNES C4 core if available (default: same as --with-assembler) >- --with(out)-zsnesfx Use ZSNES SuperFX core if available (default: same as --with-assembler) >- --with(out)-correct-vram-reads Use Correct VRAM read logic (default: with) >-@@ -5873,7 +5874,9 @@ >- ZSNESFX='#ZSNESFX=1' >- ZSNESC4='#ZSNESC4=1' >- ASMCPU='' >-+if test yes = "$with_mmx"; then >- ASMKREED='#ASMKREED=1' >-+fi >- SDD1_DECOMP='#SDD1_DECOMP=1' >- JMA='#JMA=1' >- SPC700ASM='' >-@@ -5995,6 +5998,60 @@ >- echo "$as_me:$LINENO: result: $snes9x_cv_i386_cpu" >&5 >- echo "${ECHO_T}$snes9x_cv_i386_cpu" >&6 >- >-+echo "$as_me:$LINENO: checking if the OS is FreeBSD" >&5 >-+echo $ECHO_N "checking if the OS is FreeBSD... $ECHO_C" >&6 >-+if test "${snes9x_cv_freebsd_os+set}" = set; then >-+ echo $ECHO_N "(cached) $ECHO_C" >&6 >-+else >-+ >-+ cat >conftest.$ac_ext <<_ACEOF >-+#line 3885 "configure" >-+/* confdefs.h. */ >-+_ACEOF >-+cat confdefs.h >>conftest.$ac_ext >-+cat >>conftest.$ac_ext <<_ACEOF >-+/* end confdefs.h. */ >-+ >-+#ifdef __FreeBSD__ >-+/* */ >-+#else >-+#error Not FreeBSD. >-+#endif >-+ >-+int >-+main () >-+{ >-+ >-+ ; >-+ return 0; >-+} >-+_ACEOF >-+rm -f conftest.$ac_objext >-+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 >-+ (eval $ac_compile) 2>&5 >-+ ac_status=$? >-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 >-+ (exit $ac_status); } && >-+ { ac_try='test -s conftest.$ac_objext' >-+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 >-+ (eval $ac_try) 2>&5 >-+ ac_status=$? >-+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 >-+ (exit $ac_status); }; }; then >-+ snes9x_cv_freebsd_os=yes >-+else >-+ echo "$as_me: failed program was:" >&5 >-+sed 's/^/| /' conftest.$ac_ext >&5 >-+ >-+snes9x_cv_freebsd_os=no >-+fi >-+rm -f conftest.$ac_objext conftest.$ac_ext >-+fi >-+ >-+echo "$as_me:$LINENO: result: $snes9x_cv_freebsd_os" >&5 >-+echo "${ECHO_T}$snes9x_cv_freebsd_os" >&6 >-+ >-+ >- echo "$as_me:$LINENO: checking if the OS is Linux" >&5 >- echo $ECHO_N "checking if the OS is Linux... $ECHO_C" >&6 >- if test "${snes9x_cv_linux_os+set}" = set; then >-@@ -6365,7 +6422,10 @@ >- with_joystick=yes >- fi; >- >--if test yes = "$snes9x_cv_linux_os" -a yes = "$with_joystick"; then >-+if test yes = "$snes9x_cv_freebsd_os" -a yes = "$with_joystick"; then >-+ JOYDEFINES=' -DJOYSTICK_SUPPORT' >-+ SYSLIBS="$SYSLIBS"' -lusbhid' >-+elif test yes = "$snes9x_cv_linux_os" -a yes = "$with_joystick"; then >- JOYDEFINES=' -DJOYSTICK_SUPPORT' >- else >- with_joystick="no" >-@@ -6396,6 +6456,13 @@ >- CPUINC='-Ish' >- fi >- >-+# Check whether --with-mmx or --without-mmx was given. >-+if test "${with_mmx+set}" = set -a yes = "$with_assembler"; then >-+ withval="$with_mmx" >-+ >-+else >-+ with_mmx=no >-+fi; >- >- # Check whether --with-sdd1-decomp or --without-sdd1-decomp was given. >- if test "${with_sdd1_decomp+set}" = set; then >-@@ -9758,7 +9825,7 @@ >- cat >>conftest.$ac_ext <<_ACEOF >- /* end confdefs.h. */ >- >--#if defined(__linux) || defined(__sun) || defined(__sgi) >-+#if defined(__linux) || defined(__sun) || defined(__sgi) || defined(__FreeBSD__) >- /* */ >- #else >- #error No sound for this platform >-@@ -10013,6 +10080,7 @@ >- sound support....... $snes9x_cv_sound >- display system...... $snes9x_info_display >- joystick support.... $with_joystick >-+using mmx code.... $with_mmx >- netplay support..... $with_netplay >- SDD1 decompression.. $with_sdd1_decomp >- JMA decompression... $with_jma_decomp >diff -ruN snes9x.orig/files/patch-memmap.cpp snes9x/files/patch-memmap.cpp >--- snes9x.orig/files/patch-memmap.cpp 1970-01-01 03:00:00.000000000 +0300 >+++ snes9x/files/patch-memmap.cpp 2012-11-30 01:48:45.000000000 +0400 >@@ -0,0 +1,20 @@ >+--- memmap.cpp.orig 2011-04-24 17:38:10.000000000 +0400 >++++ memmap.cpp 2012-11-30 01:47:27.000000000 +0400 >+@@ -2069,7 +2069,7 @@ >+ size_t ignore; >+ ignore = fwrite((char *) Multi.sramB, size, 1, file); >+ fclose(file); >+- #ifdef __linux >++ #ifdef __FreeBSD__ >+ ignore = chown(name, getuid(), getgid()); >+ #endif >+ } >+@@ -2089,7 +2089,7 @@ >+ size_t ignore; >+ ignore = fwrite((char *) SRAM, size, 1, file); >+ fclose(file); >+- #ifdef __linux >++ #ifdef __FreeBSD__ >+ ignore = chown(sramName, getuid(), getgid()); >+ #endif >+ >diff -ruN snes9x.orig/files/patch-port.h snes9x/files/patch-port.h >--- snes9x.orig/files/patch-port.h 1970-01-01 03:00:00.000000000 +0300 >+++ snes9x/files/patch-port.h 2012-11-30 02:27:13.000000000 +0400 >@@ -0,0 +1,14 @@ >+--- port.h.orig 2011-04-24 17:38:10.000000000 +0400 >++++ port.h 2012-11-30 02:26:23.000000000 +0400 >+@@ -327,6 +327,11 @@ >+ #define SYS_CONFIG_FILE "/etc/snes9x/snes9x.conf" >+ #endif >+ >++#ifdef __FreeBSD__ >++#define TITLE "Snes9x: FreeBSD" >++#define SYS_CONFIG_FILE "%%PREFIX%%/etc/snes9x/snes9x.conf" >++#endif >++ >+ #ifndef TITLE >+ #define TITLE "Snes9x" >+ #endif >diff -ruN snes9x.orig/files/patch-snes9x.cpp snes9x/files/patch-snes9x.cpp >--- snes9x.orig/files/patch-snes9x.cpp 1970-01-01 03:00:00.000000000 +0300 >+++ snes9x/files/patch-snes9x.cpp 2012-11-30 03:11:51.000000000 +0400 >@@ -0,0 +1,31 @@ >+--- snes9x.cpp.orig 2011-04-24 17:38:10.000000000 +0400 >++++ snes9x.cpp 2012-11-30 02:51:24.000000000 +0400 >+@@ -199,6 +199,7 @@ >+ #endif >+ >+ #define S9X_CONF_FILE_NAME "snes9x.conf" >++#define S9X_CONF_FILE_LOC ".config/snes9x" >+ >+ static char *rom_filename = NULL; >+ >+@@ -346,13 +347,18 @@ >+ >+ if (!skip) >+ { >++ std::string fname; >++ >++ fname = S9xGetDirectory(HOME_DIR); >++ fname += SLASH_STR S9X_CONF_FILE_LOC; >++ fname += SLASH_STR S9X_CONF_FILE_NAME; >++ try_load_config_file(fname.c_str(), conf); >++ >+ #ifdef SYS_CONFIG_FILE >+ try_load_config_file(SYS_CONFIG_FILE, conf); >+ S9xParsePortConfig(conf, 0); >+ #endif >+ >+- std::string fname; >+- >+ fname = S9xGetDirectory(DEFAULT_DIR); >+ fname += SLASH_STR S9X_CONF_FILE_NAME; >+ try_load_config_file(fname.c_str(), conf); >diff -ruN snes9x.orig/files/patch-unix-configure snes9x/files/patch-unix-configure >--- snes9x.orig/files/patch-unix-configure 1970-01-01 03:00:00.000000000 +0300 >+++ snes9x/files/patch-unix-configure 2012-11-30 04:25:48.000000000 +0400 >@@ -0,0 +1,10 @@ >+--- unix/configure.orig 2011-04-24 17:38:10.000000000 +0400 >++++ unix/configure 2012-11-30 04:12:07.000000000 +0400 >+@@ -4520,6 +4520,7 @@ >+ if test "x$enable_gamepad" = "xyes"; then >+ if test "x$snes9x_cv_linux_os" = "xyes"; then >+ S9XDEFS="$S9XDEFS -DJOYSTICK_SUPPORT" >++ S9XLIBS="$S9XLIBS -lusbhid" >+ else >+ { echo "$as_me:$LINENO: WARNING: Your OS is not Linux. Build without gamepad support." >&5 >+ echo "$as_me: WARNING: Your OS is not Linux. Build without gamepad support." >&2;} >diff -ruN snes9x.orig/files/patch-unix-unix.cpp snes9x/files/patch-unix-unix.cpp >--- snes9x.orig/files/patch-unix-unix.cpp 1970-01-01 03:00:00.000000000 +0300 >+++ snes9x/files/patch-unix-unix.cpp 2012-11-30 03:36:13.000000000 +0400 >@@ -0,0 +1,331 @@ >+--- unix/unix.cpp.orig 2011-04-24 17:38:10.000000000 +0400 >++++ unix/unix.cpp 2012-11-30 03:24:29.000000000 +0400 >+@@ -202,7 +202,12 @@ >+ #include <sys/mman.h> >+ #endif >+ #ifdef JOYSTICK_SUPPORT >+-#include <linux/joystick.h> >++//#include <linux/joystick.h> >++#endif >++ >++#ifdef __FreeBSD__ >++typedef sig_t SIG_PF; >++#include <err.h> >+ #endif >+ >+ #include "snes9x.h" >+@@ -242,7 +247,11 @@ >+ static volatile bool8 block_signal = FALSE; >+ static volatile bool8 block_generate_sound = FALSE; >+ >++#ifdef __FreeBSD__ >++static const char *sound_device = "/dev/dsp"; >++#else >+ static const char *sound_device = NULL; >++#endif >+ >+ static const char *s9x_base_dir = NULL, >+ *rom_filename = NULL, >+@@ -301,8 +310,65 @@ >+ >+ #ifdef JOYSTICK_SUPPORT >+ static uint8 js_mod[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; >+-static int js_fd[8] = { -1, -1, -1, -1, -1, -1, -1, -1 }; >+-static const char *js_device[8] = { "/dev/js0", "/dev/js1", "/dev/js2", "/dev/js3", "/dev/js4", "/dev/js5", "/dev/js6", "/dev/js7" }; >++#define JOYSTICK_MAX_DEVICES 4 >++int JoystickShift = 0; >++static const char *js_device[4] = { "/dev/uhid0", "/dev/uhid1", "/dev/uhid2", "/dev/uhid3" }; >++#if defined(__FreeBSD__) >++#include <sys/types.h> >++#include <sys/param.h> >++ >++extern "C" { >++#define class klass >++#include <dev/usb/usb.h> >++#include <dev/usb/usbhid.h> >++#undef class >++ >++#include <usbhid.h> >++} >++ >++#define JOYSTICK_MAX_BUTTONS 16 >++ >++#define JOYSTICK_MAP_BUTTON_INITIALIZER \ >++ { \ >++ SNES_Y_MASK, SNES_B_MASK, SNES_A_MASK, \ >++ SNES_X_MASK, SNES_TL_MASK, SNES_TR_MASK, \ >++ SNES_TL_MASK, SNES_TR_MASK, \ >++ SNES_SELECT_MASK, SNES_START_MASK, 0, 0, 0, 0, 0, 0 \ >++ } >++ >++int js_map_button[JOYSTICK_MAX_BUTTONS][16] = { >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER, >++ JOYSTICK_MAP_BUTTON_INITIALIZER >++}; >++struct js_range { >++ int min, max, lower_third, higher_third; >++}; >++struct js_info { >++ char *buf; >++ int reportlen; >++ int offset; >++ struct js_range x, y; >++ int buttons; >++ struct hid_item *hids; >++ int fd; >++ int joy; >++} js_info[4]; >++int js_count = 0; >++#endif >+ #endif >+ >+ #ifdef NETPLAY_SUPPORT >+@@ -464,15 +530,44 @@ >+ if (!strcasecmp(argv[i], "-nogamepad")) >+ unixSettings.JoystickEnabled = FALSE; >+ else >+- if (!strncasecmp(argv[i], "-paddev", 7) && >+- argv[i][7] >= '1' && argv[i][7] <= '8' && argv[i][8] == '\0') >+- { >+- int j = argv[i][7] - '1'; >++#ifdef __FreeBSD__ >++ if (strcasecmp(argv[i], "-joyshift") == 0) >++ JoystickShift = 1; >++ else >++#endif >++ if (strncasecmp(argv[i], "-paddev", sizeof("-paddev") - 1) == 0) { >++ char *end, *snum = argv[i] + sizeof("-paddev") - 1; >++ unsigned long num; >+ >+- if (i + 1 < argc) >+- js_device[j] = argv[++i]; >++ if (*snum == '\0' || argc < i + 1) >++ S9xUsage(); >++ if ((num = strtoul(snum, &end, 10)) < JOYSTICK_MAX_DEVICES && >++ num > 0 && *end == '\0') >++ js_device[num - 1] = argv[++i]; >+ else >++ S9xUsage (); >++ } >++ else if (strncasecmp(argv[i], "-joymap", sizeof("-joymap") - 1) == 0) { >++ static const int button_masks[] = { >++ SNES_A_MASK, SNES_B_MASK, SNES_X_MASK, SNES_Y_MASK, >++ SNES_TL_MASK, SNES_TR_MASK, SNES_START_MASK, SNES_SELECT_MASK >++ }; >++ char *end, *snum = argv[i] + sizeof("-joymap") - 1; >++ unsigned long num; >++ int *js_buttons, b; >++ >++ if (argc < i + (sizeof(button_masks) / sizeof(int)) || *snum == '\0') >++ S9xUsage(); >++ num = strtoul(snum, &end, 10); >++ if (*end != '\0') >+ S9xUsage(); >++ if (num == 0 || num > 4) /* hardcode: max joysticks */ >++ S9xUsage(); >++ js_buttons = js_map_button[num - 1]; >++ for (b = 0; b < (sizeof(button_masks) / sizeof(int)); b++) >++ if ((num = strtoul(argv[++i], &end, 10)) <= 16 && num != 0 && >++ end == '\0') >++ js_buttons[num - 1] = button_masks[b]; >+ } >+ else >+ #endif >+@@ -1261,7 +1356,7 @@ >+ } >+ >+ #ifdef JOYSTICK_SUPPORT >+- >++#ifdef __linux >+ static void InitJoysticks (void) >+ { >+ #ifdef JSIOCGVERSION >+@@ -1347,7 +1442,174 @@ >+ } >+ #endif >+ } >++#endif >++#ifdef __FreeBSD__ >++ >++/* >++ * USB HID code for FreeBSD/NetBSD >++ * Brian Feldman <green@FreeBSD.org> >++ * >++ * Reference used: >++ * X-Mame USB HID joystick driver for NetBSD. >++ * >++ * Written by Krister Walfridsson <cato@df.lth.se> >++ */ >++ >++int >++InitJoystickFd(int fd, const char *dev) { >++ report_desc_t rd; >++ struct hid_data *d; >++ struct hid_item h, new_h; >++ struct js_info *my_info; >++ int reportlen, report_id, is_joystick; >++ >++ my_info = &js_info[js_count]; >++ rd = hid_get_report_desc(fd); >++ if (rd == 0) { >++ warn("%s", dev); >++ return (-1); >++ } >++ report_id = 0; >++ reportlen = hid_report_size(rd, hid_input, report_id); >++ my_info->buf = (char *)malloc(reportlen); >++ if (my_info->buf == NULL) >++ err(1, "malloc"); >++ my_info->reportlen = reportlen; >++ my_info->offset = report_id != 0; >++ my_info->buttons = 0; >++ my_info->hids = NULL; >++ is_joystick = 0; >++ for (d = hid_start_parse(rd, 1 << hid_input, report_id); hid_get_item(d, &h);) { >++ int usage, page, link_it = 0; >++ struct js_range *axis; >++ >++ page = HID_PAGE(h.usage); >++ usage = HID_USAGE(h.usage); >++ if (!is_joystick) >++ is_joystick = (h.kind == hid_collection && >++ page == HUP_GENERIC_DESKTOP && >++ (usage == HUG_JOYSTICK || usage == HUG_GAME_PAD)); >++ if (h.kind != hid_input || !is_joystick) >++ continue; >++ axis = NULL; >++ if (page == HUP_GENERIC_DESKTOP) { >++ switch (usage) { >++ case HUG_X: >++ case HUG_RX: >++ axis = &my_info->x; >++ break; >++ case HUG_Y: >++ case HUG_RY: >++ axis = &my_info->y; >++ break; >++ } >++ } >++ if (axis != NULL) { >++ axis->min = h.logical_minimum; >++ axis->max = h.logical_maximum; >++ axis->lower_third = axis->min + (axis->max - axis->min) / 3; >++ axis->higher_third = axis->min + (axis->max - axis->min) * 2 / 3; >++ link_it = 1; >++ } >++ if (!link_it) { >++ if (page != HUP_BUTTON || usage > 16) >++ continue; >++ if (usage > my_info->buttons) >++ my_info->buttons = usage; >++ } >++ new_h = h; >++ new_h.next = my_info->hids; >++ my_info->hids = (struct hid_item *) malloc(sizeof(*my_info->hids)); >++ if (my_info->hids == NULL) >++ err(1, "malloc"); >++ *my_info->hids = new_h; >++ } >++ printf("Joystick %s: %d buttons, X range %d - %d, Y range %d - %d\n", >++ dev, my_info->buttons, my_info->x.min, my_info->x.max, >++ my_info->y.min, my_info->y.max); >++ my_info->fd = fd; >++ if (JoystickShift) { >++ my_info->joy = js_count + 1; >++ } else >++ my_info->joy = js_count; >++ return (0); >++} >++ >++static void InitJoysticks() { >++ int i, fd; >++ >++ for (i = 0; i < (sizeof(js_device) / sizeof(js_device[0])); i++) { >++ fd = open(js_device[i], O_RDONLY | O_NONBLOCK); >++ if (fd == -1) >++ continue; >++ if (InitJoystickFd(fd, js_device[i]) == 0) >++ js_count++; >++ else >++ close(fd); >++ } >++} >++ >++static void ReadJoysticks() { >++ struct hid_item *h; >++ int page, usage, njoy, joy; >++ >++ for (njoy = 0; njoy < js_count; njoy++) { >++ struct js_info *jsi; >+ >++ jsi = &js_info[njoy]; >++ joy = jsi->joy; >++ >++ if (read(jsi->fd, jsi->buf, jsi->reportlen) != jsi->reportlen) >++ continue; >++ for (h = jsi->hids; h != NULL; h = h->next) { >++ int d; >++ >++ d = hid_get_data(jsi->buf + jsi->offset, h); >++ page = HID_PAGE(h->usage); >++ usage = HID_USAGE(h->usage); >++ >++ switch (page) { >++ case HUP_GENERIC_DESKTOP: >++ switch (usage) { >++ case HUG_X: >++ case HUG_RX: >++ if (d < jsi->x.lower_third) { >++ joypads[joy] |= SNES_LEFT_MASK; >++ joypads[joy] &= ~SNES_RIGHT_MASK; >++ } else if (d < jsi->x.higher_third) { >++ joypads[joy] &= ~SNES_LEFT_MASK; >++ joypads[joy] &= ~SNES_RIGHT_MASK; >++ } else { >++ joypads[joy] &= ~SNES_LEFT_MASK; >++ joypads[joy] |= SNES_RIGHT_MASK; >++ } >++ break; >++ case HUG_Y: >++ case HUG_RY: >++ if (d < jsi->y.lower_third) { >++ joypads[joy] |= SNES_UP_MASK; >++ joypads[joy] &= ~SNES_DOWN_MASK; >++ } else if (d < jsi->y.higher_third) { >++ joypads[joy] &= ~SNES_UP_MASK; >++ joypads[joy] &= ~SNES_DOWN_MASK; >++ } else { >++ joypads[joy] &= ~SNES_UP_MASK; >++ joypads[joy] |= SNES_DOWN_MASK; >++ } >++ break; >++ } >++ break; >++ case HUP_BUTTON: >++ if (d) >++ joypads[joy] |= js_map_button[njoy][usage - 1]; >++ else >++ joypads[joy] &= ~js_map_button[njoy][usage - 1]; >++ break; >++ } >++ } >++ } >++} >++#endif // defined(__FreeBSD__) >+ #endif >+ >+ static void SoundTrigger (void) >diff -ruN snes9x.orig/files/patch-unzip-unzip.h snes9x/files/patch-unzip-unzip.h >--- snes9x.orig/files/patch-unzip-unzip.h 1970-01-01 03:00:00.000000000 +0300 >+++ snes9x/files/patch-unzip-unzip.h 2012-11-30 03:05:39.000000000 +0400 >@@ -0,0 +1,34 @@ >+--- unzip/unzip.h.orig 2011-04-24 17:38:10.000000000 +0400 >++++ unzip/unzip.h 2012-11-30 03:04:33.000000000 +0400 >+@@ -45,12 +45,10 @@ >+ #ifndef _unz_H >+ #define _unz_H >+ >+-#ifdef __cplusplus >+-extern "C" { >+-#endif >++#include <sys/types.h> >+ >+ #ifndef _ZLIB_H >+-#include "zlib.h" >++#include <zlib.h> >+ #endif >+ >+ #ifndef _ZLIBIOAPI_H >+@@ -58,9 +56,15 @@ >+ #endif >+ >+ #ifdef HAVE_BZIP2 >+-#include "bzlib.h" >++#include <bzlib.h> >++#endif >++ >++#ifdef __cplusplus >++extern "C" { >+ #endif >+ >++#define ZEXPORT >++ >+ #define Z_BZIP2ED 12 >+ >+ #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) >diff -ruN snes9x.orig/files/pkg-message.in snes9x/files/pkg-message.in >--- snes9x.orig/files/pkg-message.in 2006-12-27 20:27:37.000000000 +0300 >+++ snes9x/files/pkg-message.in 2012-11-30 19:07:32.000000000 +0400 >@@ -4,7 +4,7 @@ > > 1) You can run the emulator using: > >- # (o)snes9x -y2 -ts /path/to/rom_file >+ # snes9x -v6 /path/to/rom_file > > 2) You can see all options that you can use with snes9x at: > >@@ -12,15 +12,15 @@ > > or only typing: > >- # (o)snes9x >+ # snes9x > >-3) Also you can define a config file, see an example at: >+3) Also you can define a config file in > >- %%DOCSDIR%%/snes9x.conf.default >+${HOME}/.config/snes9x/snes9x.conf or > >- and you can select this config file using: >+${PREFIX}/etc/snes9x/snes9x.conf (default conf file) > >- # (o)snes9x -conf /path/to/conf_file >+Example in ${DOCSDIR}/snes9x.conf.default > > 4) Enjoy it ;)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 174017
: 129945