Snes9x is a portable, freeware Super Nintendo Entertainment System (SNES)

emulator. It basically allows you to play most games designed for the SNES
and Super Famicom Nintendo game systems on your PC or Workstation; which
includes some real gems that were only ever released in Japan.

TODO:
* Black screen and no sound on NetBSD/sparc64.
* Loading/saving is broken.
* PNG support for screenshots.

With permission from Thomas Klausner.
This commit is contained in:
Leonard Schmidt 2005-09-08 10:22:22 +00:00 committed by Thomas Klausner
parent 19e04324b1
commit 1415f85456
22 changed files with 897 additions and 0 deletions

4
snes9x/DESCR Normal file
View file

@ -0,0 +1,4 @@
Snes9x is a portable, freeware Super Nintendo Entertainment System (SNES)
emulator. It basically allows you to play most games designed for the SNES
and Super Famicom Nintendo game systems on your PC or Workstation; which
includes some real gems that were only ever released in Japan.

84
snes9x/Makefile Normal file
View file

@ -0,0 +1,84 @@
# $NetBSD: Makefile,v 1.1.1.1 2005/09/08 10:22:22 leonardschmidt Exp $
#
DISTNAME= snes9x-${S9X_VER}-src
PKGNAME= ${DISTNAME:S/-src//}
CATEGORIES= emulators
MASTER_SITES= http://www.lysator.liu.se/snes9x/${S9X_VER}/ \
http://www.ipherswipsite.com/files/snes9x/ \
http://www.zophar.net/Files/ \
http://vincent.grigorieff.free.fr/snes9x/
MAINTAINER= jmcneill@NetBSD.org
HOMEPAGE= http://www.snes9x.com/
COMMENT= Super Nintendo Entertainment System (SNES) emulator
WRKSRC= ${WRKDIR}/${PKGNAME}-src/snes9x
GNU_CONFIGURE= yes
USE_TOOLS+= gmake
PTHREAD_OPTS= require
INSTALLATION_DIRS= bin
S9X_VER= 1.43
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/offsets ${PREFIX}/bin
${INSTALL_PROGRAM} ${WRKSRC}/snes9x ${PREFIX}/bin
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/snes9x
${INSTALL_DATA} ${WRKDIR}/${DISTNAME}/documentation/Le_FAQ_de_Snes9x.txt ${PREFIX}/share/doc/snes9x
${INSTALL_DATA} ${WRKSRC}/changes.txt ${PREFIX}/share/doc/snes9x
${INSTALL_DATA} ${WRKSRC}/copyright.h ${PREFIX}/share/doc/snes9x
${INSTALL_DATA} ${WRKSRC}/hardware.txt ${PREFIX}/share/doc/snes9x
${INSTALL_DATA} ${WRKDIR}/${DISTNAME}/license.txt ${PREFIX}/share/doc/snes9x
${INSTALL_DATA} ${WRKSRC}/doc/porting.txt ${PREFIX}/share/doc/snes9x
${INSTALL_DATA} ${WRKSRC}/problems.txt ${PREFIX}/share/doc/snes9x
${INSTALL_DATA} ${WRKDIR}/${DISTNAME}/documentation/readme.txt ${PREFIX}/share/doc/snes9x
${INSTALL_DATA} ${WRKDIR}/${DISTNAME}/readme.unix ${PREFIX}/share/doc/snes9x
.include "../../mk/bsd.prefs.mk"
PKG_OPTIONS_VAR= PKG_OPTIONS.snes9x
.if ${MACHINE_ARCH} == "i386"
PKG_SUPPORTED_OPTIONS+= mmx
.endif
.include "../../mk/bsd.options.mk"
MAKE_ENV+= THREAD_SOUND=1
.if ${MACHINE_ARCH} == "i386"
MAKE_ENV+= USING_I386=1
.if ${OBJECT_FMT} == "a.out"
MAKE_ENV+= FILEFORMAT=aoutb
MAKE_ENV+= _ASM_UNDERBARS=1
.else
MAKE_ENV+= FILEFORMAT=elf
.endif
MAKE_ENV+= ZSNESFX=1
MAKE_ENV+= ZSNESC4=1
MAKE_ENV+= ASMCPU=1
.if !empty(PKG_OPTIONS:Mmmx)
MAKE_ENV+= ASMKREED=1
.endif
.endif
.if ${MACHINE_ARCH} == "i386"
BUILD_DEPENDS+= nasm>=0.98:../../devel/nasm
CONFIGURE_ARGS+= --with-assembler
.endif
.if exists(${X11BASE}/lib/libXxf86dga.a)
MAKE_ENV+= NETBSD_USE_DGA=1
.endif
.if exists(/usr/include/usb.h) || exists(/usr/include/usbhid.h)
MAKE_ENV+= USBJOY=1
.if exists(/usr/include/usbhid.h)
MAKE_ENV+= USBHID_H=1
.endif
.endif
.include "../../devel/zlib/buildlink3.mk"
.include "../../graphics/png/buildlink3.mk"
.include "../../mk/ossaudio.buildlink3.mk"
.include "../../mk/pthread.buildlink3.mk"
.include "../../mk/x11.buildlink3.mk"
.include "../../mk/bsd.pkg.mk"

13
snes9x/PLIST Normal file
View file

@ -0,0 +1,13 @@
@comment $NetBSD: PLIST,v 1.1.1.1 2005/09/08 10:22:22 leonardschmidt Exp $
bin/offsets
bin/snes9x
share/doc/snes9x/Le_FAQ_de_Snes9x.txt
share/doc/snes9x/changes.txt
share/doc/snes9x/copyright.h
share/doc/snes9x/hardware.txt
share/doc/snes9x/license.txt
share/doc/snes9x/porting.txt
share/doc/snes9x/problems.txt
share/doc/snes9x/readme.txt
share/doc/snes9x/readme.unix
@dirrm share/doc/snes9x

3
snes9x/TODO Normal file
View file

@ -0,0 +1,3 @@
* Black screen and no sound on NetBSD/sparc64.
* Loading/saving is broken.
* PNG support for screenshots.

22
snes9x/distinfo Normal file
View file

@ -0,0 +1,22 @@
$NetBSD: distinfo,v 1.1.1.1 2005/09/08 10:22:22 leonardschmidt Exp $
SHA1 (snes9x-1.43-src.tar.gz) = c6883c451aeb442030862ec19a8dca25ee02d82c
RMD160 (snes9x-1.43-src.tar.gz) = d2003f7afb208109405b41f4eec586b93518f9b2
Size (snes9x-1.43-src.tar.gz) = 1016251 bytes
SHA1 (patch-aa) = d9a27a1d3c167dc79f4286476def1e91011dd963
SHA1 (patch-ab) = 4f7c224b03dec3148efa986395459e439fe70726
SHA1 (patch-ac) = 2059cdbd2b77cf73be69a5c27dc9e34bde3752c6
SHA1 (patch-ad) = d300b875abb16deae6e3003aa7fd5e31865943e5
SHA1 (patch-ae) = d44f00dc9ba48414dbd91d97d845b2995f84da17
SHA1 (patch-af) = 81b6f86fb4e2c0d73f6756cb5c5e7dfaca409b93
SHA1 (patch-ag) = 21cfc43e70330327515fefe930f5a6fb108f866c
SHA1 (patch-ah) = 319188168aadc3366c1e87c2dec4dd448677a412
SHA1 (patch-ai) = 5e670f4c047b663d7022b7fe9646dacd8a2be25d
SHA1 (patch-aj) = a815011055adca4eeb3c15db535a8f82b2470ff6
SHA1 (patch-ak) = 1ec6d127d089e3fb80e952cb357963aa13718ae5
SHA1 (patch-al) = e101341e5967bd34fa3c1d10b4a32ff04f23f7b5
SHA1 (patch-am) = e05afe3c83add0288350ea86a3aeec331f67549b
SHA1 (patch-an) = ae01ad39b77e77887e42ab22f544cf91da1eeed7
SHA1 (patch-ao) = df2ee5f5741c6713a59a8f06257191d45d3fc7c9
SHA1 (patch-ap) = f2e5740d5f17692637f5136ab8c2267700d77c67
SHA1 (patch-aq) = 4793514ea89e33ddee65cec44e99fa5bbdd0653d

97
snes9x/patches/patch-aa Normal file
View file

@ -0,0 +1,97 @@
$NetBSD: patch-aa,v 1.1.1.1 2005/09/08 10:22:23 leonardschmidt Exp $
--- Makefile.in.orig 2004-12-30 22:15:44.000000000 +0000
+++ Makefile.in
@@ -59,11 +59,20 @@ C4DEPENDS=c_c4
C4NO_DEPENDS=zsnes_c4
endif
+ifdef NETBSD_USE_DGA
+DGADEFINES=-DUSE_DGA_EXTENSION -DUSE_VIDMODE_EXTENSION
+DGALIBS=-lXxf86dga -lXxf86vm
+endif
+
ifdef SPC700ASM
SOUNDOBJ=spctool/spc700.o spctool/dsp.o spctool.o spctool/soundmod.o @I386SPC@
SOUNDDEFINES=-DSPCTOOL
else
+ifdef USING_I386
SOUNDOBJ=spc700.o soundux.o apu.o @I386SPC@
+else
+SOUNDOBJ=spc700.o soundux.o apu.o
+endif
SOUNDDEFINES=-DSPC700_C
endif
@@ -100,6 +109,20 @@ KREEDOBJ=2xsai.o
endif
endif
+ifdef USBJOY
+ifdef USBHID_H
+USBJOYDEFINES=-DJOYSTICK_SUPPORT -DHAVE_USBHID_H
+EXTRALIBS+=-lusbhid
+else
+USBJOYDEFINES=-DJOYSTICK_SUPPORT
+EXTRALIBS+=-lusb
+endif
+endif
+
+ifdef _ASM_UNDERBARS
+EXTRADEFINES+=-D_ASM_UNDERBARS
+endif
+
ifdef SDD1_DECOMP
SDD1OBJ=sdd1emu.o
ifdef SDD1_VERIFY
@@ -136,9 +159,10 @@ OBJECTS += jma/s9x-jma.o jma/7zlzma.o jm
JMADEFINES=-DJMA_SUPPORT -fexceptions
endif
+EXTRALIBS+= $(LIBOSSAUDIO)
ifdef THREAD_SOUND
-CPUDEFINES += -DUSE_THREADS
-EXTRALIBS += -lpthread
+CPUDEFINES += -DUSE_THREADS -I${BUILDLINK_DIR}/include
+EXTRALIBS += -Wl,-R${LOCALBASE}/lib -L${BUILDLINK_DIR}/lib -lpthread
endif
ifdef GLIDE
@@ -206,7 +230,9 @@ $(AIDODEFINES) \
$(KREEDDEFINES) \
$(SDD1DEFINES) \
$(JOYDEFINES) \
--DNO_INLINE_SET_GET @SYSDEFINES@
+$(USBJOYDEFINES) \
+$(DGADEFINES) \
+$(EXTRADEFINES)
#-DOLD_COLOUR_BLENDING
#-DSOUND
@@ -222,7 +248,7 @@ CFLAGS=$(CCFLAGS)
.SUFFIXES: .o .cpp .c .cc .h .m .i .S .asm .obj .O .CPP .C .ASM
#FIXME: Why is this set statically?
-#LDLIBS = -L/usr/X11R6/lib
+LDLIBS += -Wl,-R${X11BASE}/lib
# -L../zlib
ifdef GLIDE
@@ -262,7 +288,7 @@ offsets: offsets.o
./offsets >$(srcdir)/$(CPU)/offsets.h #FIXME: Move to builddir
snes9x: $(OBJECTS) unix/x11.o $(AIDOOBJS)
- $(CCC) $(INCLUDES) -o $@ $(OBJECTS) $(AIDOOBJS) $(GLIDEOBJS) $(OPENGLOBJS) unix/x11.o $(LDLIBS) $(GLIDELIBS) $(OPENGLLIBS) @SYSLIBS@ -lXext -lX11 $(EXTRALIBS) -lm
+ $(CCC) $(INCLUDES) -o $@ $(OBJECTS) $(AIDOOBJS) $(GLIDEOBJS) $(OPENGLOBJS) unix/x11.o $(LDLIBS) $(GLIDELIBS) $(OPENGLLIBS) @SYSLIBS@ -lXext -lX11 $(EXTRALIBS) $(DGALIBS) -lm
ssnes9x: $(OBJECTS) unix/svga.o
$(CCC) $(INCLUDES) -o $@ $(OBJECTS) $(GLIDEOBJS) unix/svga.o $(LDLIBS) $(GLIDELIBS) @SYSLIBS@ -lvga -lvgagl $(EXTRALIBS) -lm
@@ -302,7 +328,7 @@ s9xserver: $(SERVER_OBJECTS)
sh-elf-as -little $(srcdir)/$*.s -o $@
.asm.o:
- $(NASM) -f elf $(FXDEFINES) -I$(srcdir)/ -I$(srcdir)/$(CPU)/ -o $@ $(srcdir)/$*.asm
+ $(NASM) -f ${FILEFORMAT} $(FXDEFINES) $(EXTRADEFINES) -I$(srcdir)/ -I$(srcdir)/$(CPU)/ -o $@ $(srcdir)/$*.asm
.obj.o:
cp $*.obj $*.o

13
snes9x/patches/patch-ab Normal file
View file

@ -0,0 +1,13 @@
$NetBSD: patch-ab,v 1.1.1.1 2005/09/08 10:22:23 leonardschmidt Exp $
--- i386/asmstruc.h.orig 2004-12-30 22:15:44.000000000 +0000
+++ i386/asmstruc.h
@@ -86,7 +86,7 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
*******************************************************************************/
-#if defined(__DJGCC) || defined(MICROSOFT_C) || defined(_WINDOWS)
+#if defined(__DJGCC) || defined(MICROSOFT_C) || defined(_WINDOWS) || defined(_ASM_UNDERBARS)
#define S9xTraceMessage _S9xTraceMessage
#define S9xGetPPU _S9xGetPPU
#define S9xSetPPU _S9xSetPPU

17
snes9x/patches/patch-ac Normal file
View file

@ -0,0 +1,17 @@
$NetBSD: patch-ac,v 1.1.1.1 2005/09/08 10:22:23 leonardschmidt Exp $
--- 2xsai.cpp.orig 2004-12-30 22:15:47.000000000 +0000
+++ 2xsai.cpp
@@ -95,13 +95,6 @@
#include "port.h"
#include "gfx.h"
-#if (defined(USE_X86_ASM) && (defined (__i386__) || defined (__i486__) || \
- defined (__i586__) || defined (__WIN32__) || defined (__DJGPP)))
-# ifndef MMX
-# define MMX
-# endif
-#endif
-
extern "C"
{

18
snes9x/patches/patch-ad Normal file
View file

@ -0,0 +1,18 @@
$NetBSD: patch-ad,v 1.1.1.1 2005/09/08 10:22:23 leonardschmidt Exp $
--- netplay.cpp.orig 2004-12-30 22:15:45.000000000 +0000
+++ netplay.cpp
@@ -126,9 +126,13 @@
#ifdef USE_THREADS
#include <pthread.h>
+#ifdef __NetBSD__
+#include <sys/sched.h>
+#else
#include <sched.h>
#include <semaphore.h>
#endif
+#endif
#include "snes9x.h"
#include "cpuexec.h"

15
snes9x/patches/patch-ae Normal file
View file

@ -0,0 +1,15 @@
$NetBSD: patch-ae,v 1.1.1.1 2005/09/08 10:22:23 leonardschmidt Exp $
--- port.h.orig 2004-12-30 22:15:47.000000000 +0000
+++ port.h
@@ -281,6 +281,10 @@ EXTERN_C void MixSound(void);
#define TITLE "Snes9X: Linux"
#endif
+#ifdef __NetBSD__
+#define TITLE "Snes9X: NetBSD"
+#endif
+
#ifndef TITLE
#define TITLE "Snes9x"
#endif

13
snes9x/patches/patch-af Normal file
View file

@ -0,0 +1,13 @@
$NetBSD: patch-af,v 1.1.1.1 2005/09/08 10:22:23 leonardschmidt Exp $
--- soundux.h.orig 2004-12-30 22:15:47.000000000 +0000
+++ soundux.h
@@ -127,7 +127,7 @@ typedef struct {
int stereo;
bool8 sixteen_bit;
bool8 encoded;
-#ifdef __sun
+#if defined(__sun) || defined(__NetBSD__)
int last_eof;
#endif
#ifdef __sgi

379
snes9x/patches/patch-ag Normal file
View file

@ -0,0 +1,379 @@
$NetBSD: patch-ag,v 1.1.1.1 2005/09/08 10:22:24 leonardschmidt Exp $
--- unix/unix.cpp.orig 2004-12-30 22:15:47.000000000 +0000
+++ unix/unix.cpp
@@ -117,13 +117,17 @@
#ifdef USE_THREADS
#include <pthread.h>
+#ifdef __NetBSD__
+#include <sys/sched.h>
+#else
#include <sched.h>
+#endif
pthread_t thread;
pthread_mutex_t mutex;
#endif
-#if !defined(NOSOUND) && defined(__linux)
+#if !defined(NOSOUND) && (defined(__linux) || defined(__NetBSD__))
#include <sys/soundcard.h>
#include <sys/mman.h>
#endif
@@ -141,6 +145,10 @@ pthread_mutex_t mutex;
//typedef void (*SIG_PF)();
//#endif
+#if defined(__NetBSD__)
+typedef void (*SIG_PF)(int);
+#endif
+
#include "snes9x.h"
#include "memmap.h"
#include "debug.h"
@@ -168,7 +176,52 @@ uint32 joypads [5] = {0};
int NumControllers = 5;
#ifdef JOYSTICK_SUPPORT
-#if defined(__linux)
+#ifdef __NetBSD__
+#ifdef HAVE_USBHID_H
+#include <usbhid.h>
+#else
+#include <usb.h>
+#endif
+#define class Class
+#include <dev/usb/usb.h>
+#include <dev/usb/usbhid.h>
+
+struct priv_joydata_struct
+{
+ struct hid_item *hids;
+ int dlen;
+ int offset;
+ char *data_buf;
+} priv_joy_data[4];
+
+int js_fd [4] = {-1, -1, -1, -1};
+int js_map_button [4][16] = {
+ {
+ SNES_A_MASK, SNES_B_MASK, SNES_X_MASK, SNES_Y_MASK,
+ SNES_TL_MASK, SNES_TR_MASK, SNES_START_MASK, SNES_SELECT_MASK,
+ 0, 0, 0, 0, 0, 0, 0, 0
+ },
+ {
+ SNES_A_MASK, SNES_B_MASK, SNES_X_MASK, SNES_Y_MASK,
+ SNES_TL_MASK, SNES_TR_MASK, SNES_START_MASK, SNES_SELECT_MASK,
+ 0, 0, 0, 0, 0, 0, 0, 0
+ },
+ {
+ SNES_A_MASK, SNES_B_MASK, SNES_X_MASK, SNES_Y_MASK,
+ SNES_TL_MASK, SNES_TR_MASK, SNES_START_MASK, SNES_SELECT_MASK,
+ 0, 0, 0, 0, 0, 0, 0, 0
+ },
+ {
+ SNES_A_MASK, SNES_B_MASK, SNES_X_MASK, SNES_Y_MASK,
+ SNES_TL_MASK, SNES_TR_MASK, SNES_START_MASK, SNES_SELECT_MASK,
+ 0, 0, 0, 0, 0, 0, 0, 0
+ }
+};
+
+char *js_device [4] = {"/dev/uhid0", "/dev/uhid1", "/dev/uhid2", "/dev/uhid3"};
+
+#endif
+#ifdef __linux
#include <linux/joystick.h>
int js_fd [4] = {-1, -1, -1, -1};
int js_map_button [4][16] = {
@@ -227,7 +280,7 @@ char *snapshot_filename = NULL;
char *SDD1_pack = NULL;
//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(__NetBSD__))
static void sigbrkhandler(int)
{
CPU.Flags |= DEBUG_MODE_FLAG;
@@ -700,6 +753,106 @@ void S9xInitInputDevices ()
#ifdef JOYSTICK_SUPPORT
void InitJoysticks ()
{
+#ifdef __NetBSD__
+ int i, size, is_joystick, report_id = 0;
+ struct hid_data *d;
+ struct hid_item h;
+ report_desc_t rd;
+
+ printf("USB joystick interface initialization...\n");
+
+ for (i = 0; i < 4; i++)
+ {
+ if ((js_fd [i] = open (js_device [i], O_RDONLY | O_NONBLOCK)) != -1)
+ {
+ if ((rd = hid_get_report_desc(js_fd [i])) == 0)
+ {
+ perror (js_device [i]);
+ close (js_fd [i]);
+ }
+
+ priv_joy_data[i].hids = NULL;
+
+#ifdef HAVE_USBHID_H
+ if (ioctl(js_fd [i], USB_GET_REPORT_ID, &report_id) < 0)
+ {
+ perror (js_device [i]);
+ close (js_fd [i]);
+ }
+
+ size = hid_report_size(rd, hid_input, report_id);
+ priv_joy_data[i].offset = 0;
+#else
+ size = hid_report_size(rd, hid_input, &report_id);
+ priv_joy_data[i].offset = (report_id != 0);
+#endif
+ if ((priv_joy_data[i].data_buf = (char*)malloc(size)) == NULL)
+ {
+ printf("error: couldn't malloc %d bytes\n", size);
+ hid_dispose_report_desc(rd);
+ }
+ priv_joy_data[i].dlen = size;
+
+ is_joystick = 0;
+#ifdef HAVE_USBHID_H
+ for (d = hid_start_parse(rd, 1 << hid_input, report_id); hid_get_item(d, &h); )
+#else
+ for (d = hid_start_parse(rd, 1 << hid_input); hid_get_item(d, &h); )
+#endif
+ {
+ int axes = 0, buttons = 0, usage, page, interesting_hid;
+
+ page = HID_PAGE(h.usage);
+ usage = HID_USAGE(h.usage);
+
+ is_joystick = is_joystick ||
+ (h.kind == hid_collection &&
+ page == HUP_GENERIC_DESKTOP &&
+ (usage == HUG_JOYSTICK || usage == HUG_GAME_PAD));
+
+ if (h.kind != hid_input)
+ continue;
+
+ if (!is_joystick)
+ continue;
+
+ interesting_hid = TRUE;
+ if (page == HUP_GENERIC_DESKTOP)
+ {
+ if (usage == HUG_X || usage == HUG_RX)
+ axes = 1;
+ else if (usage == HUG_Y || usage == HUG_RY)
+ axes = 2;
+ else if (usage == HUG_Z || usage == HUG_RZ)
+ axes = 3;
+ else
+ interesting_hid = FALSE;
+ }
+ else if (page == HUP_BUTTON)
+ {
+ if (usage > 0)
+ buttons = usage;
+ else
+ interesting_hid = FALSE;
+
+ }
+
+ if (interesting_hid)
+ {
+ h.next = priv_joy_data[i].hids;
+ priv_joy_data[i].hids = (struct hid_item *)malloc(sizeof *(priv_joy_data[i].hids));
+ if (priv_joy_data[i].hids == NULL)
+ {
+ printf("error: Not enough memory for joystick.\n");
+ break;
+ }
+ *(priv_joy_data[i].hids) = h;
+ }
+ }
+ hid_end_parse(d);
+ }
+ }
+#endif
#ifdef JSIOCGVERSION
int version;
unsigned char axes, buttons;
@@ -756,6 +909,77 @@ void InitJoysticks ()
void ReadJoysticks ()
{
+#ifdef __NetBSD__
+ int i, usage, page, d;
+ struct hid_item *h;
+
+ for (i = 0; i < 4 && js_fd [i] >= 0; i++)
+ {
+ int len;
+
+ len = read(js_fd [i], priv_joy_data[i].data_buf, priv_joy_data[i].dlen);
+ if (len < priv_joy_data[i].dlen)
+ continue;
+
+ for (h = priv_joy_data[i].hids; h; h = h->next)
+ {
+ d = hid_get_data(priv_joy_data[i].data_buf + priv_joy_data[i].offset, h);
+
+ page = HID_PAGE(h->usage);
+ usage = HID_USAGE(h->usage);
+
+ if (page == HUP_GENERIC_DESKTOP)
+ {
+ int center, trigger_point;
+
+ center = (h->logical_maximum + h->logical_minimum) / 2;
+ trigger_point = (h->logical_maximum - h->logical_minimum) / 4;
+
+ if (usage == HUG_X || usage == HUG_RX)
+ {
+ if (d < (center - trigger_point))
+ {
+ joypads [i] |= SNES_LEFT_MASK;
+ joypads [i] &= ~SNES_RIGHT_MASK;
+ continue;
+ }
+ if (d > (center + trigger_point))
+ {
+ joypads [i] &= ~SNES_LEFT_MASK;
+ joypads [i] |= SNES_RIGHT_MASK;
+ continue;
+ }
+ joypads [i] &= ~SNES_LEFT_MASK;
+ joypads [i] &= ~SNES_RIGHT_MASK;
+ }
+ if (usage == HUG_Y || usage == HUG_RY)
+ {
+ if (d < (center - trigger_point))
+ {
+ joypads [i] |= SNES_UP_MASK;
+ joypads [i] &= ~SNES_DOWN_MASK;
+ continue;
+ }
+ if (d > (center + trigger_point))
+ {
+ joypads [i] &= ~SNES_UP_MASK;
+ joypads [i] |= SNES_DOWN_MASK;
+ continue;
+ }
+ joypads [i] &= ~SNES_UP_MASK;
+ joypads [i] &= ~SNES_DOWN_MASK;
+ }
+ }
+ else if (page == HUP_BUTTON)
+ {
+ if (d == h->logical_maximum)
+ joypads [i] |= js_map_button [i][usage - 1];
+ else
+ joypads [i] &= ~js_map_button [i][usage - 1];
+ }
+ }
+ }
+#endif
#ifdef JSIOCGVERSION
struct js_event js_ev;
int i;
@@ -1048,13 +1272,13 @@ bool8 S9xOpenSnapshotFile (const char *f
if (read_only)
{
sprintf (command, "gzip -d <\"%s\"", filename);
- if (*file = popen (command, "r"))
+ if ((*file = popen (command, "r")))
return (TRUE);
}
else
{
sprintf (command, "gzip --best >\"%s\"", filename);
- if (*file = popen (command, "wb"))
+ if ((*file = popen (command, "wb")))
return (TRUE);
}
#endif
@@ -1646,7 +1870,7 @@ bool8 S9xOpenSoundDevice (int mode, bool
}
#endif
-#if !defined(NOSOUND) && defined(__linux)
+#if !defined(NOSOUND) && (defined(__linux) || defined(__NetBSD__))
static int Rates[8] =
{
0, 8000, 11025, 16000, 22050, 32000, 44100, 48000
@@ -1662,11 +1886,19 @@ bool8 S9xOpenSoundDevice (int mode, bool
/* Linux version (OSS) */
int J, K;
+#if defined(__NetBSD__)
+ if ((so.sound_fd = open ("/dev/audio", O_WRONLY)) < 0)
+ {
+ perror ("/dev/audio");
+ return (FALSE);
+ }
+#else
if ((so.sound_fd = open ("/dev/dsp", O_WRONLY)) < 0)
{
perror ("/dev/dsp");
return (FALSE);
}
+#endif
#ifdef MMAP_SOUND
if (ioctl (so.sound_fd, SNDCTL_DSP_GETCAPS, &J) < 0)
@@ -1711,14 +1943,14 @@ bool8 S9xOpenSoundDevice (int mode, bool
so.sixteen_bit = TRUE;
so.stereo = stereo;
- if (ioctl (so.sound_fd, SNDCTL_DSP_STEREO, &so.stereo) < 0)
+ if (ioctl (so.sound_fd, SNDCTL_DSP_STEREO, (void *)&so.stereo) < 0)
{
perror ("ioctl SNDCTL_DSP_STEREO");
return (FALSE);
}
so.playback_rate = Rates[mode & 0x07];
- if (ioctl (so.sound_fd, SNDCTL_DSP_SPEED, &so.playback_rate) < 0)
+ if (ioctl (so.sound_fd, SNDCTL_DSP_SPEED, (void *)&so.playback_rate) < 0)
{
perror ("ioctl SNDCTL_DSP_SPEED");
return (FALSE);
@@ -1743,7 +1975,7 @@ bool8 S9xOpenSoundDevice (int mode, bool
perror ("ioctl SNDCTL_DSP_SETFRAGMENT");
return (FALSE);
}
- ioctl (so.sound_fd, SNDCTL_DSP_GETBLKSIZE, &so.buffer_size);
+ ioctl (so.sound_fd, SNDCTL_DSP_GETBLKSIZE, (void *)&so.buffer_size);
#ifdef MMAP_SOUND
J = PCM_ENABLE_OUTPUT;
@@ -1768,7 +2000,7 @@ bool8 S9xOpenSoundDevice (int mode, bool
#endif
-#if !defined(NOSOUND) && (defined (__linux) || defined (__sun))
+#if !defined(NOSOUND) && (defined (__linux) || defined (__sun) || defined(__NetBSD__))
void S9xUnixProcessSound (void)
{
}
@@ -1810,7 +2042,7 @@ void *S9xProcessSound (void *)
}
#endif
-#if !defined(NOSOUND) && (defined (__linux) || defined (__sun))
+#if !defined(NOSOUND) && (defined (__linux) || defined (__sun) || defined(__NetBSD__))
void S9xGenerateSound ()
{
/* Linux and Sun versions */
@@ -1902,7 +2134,7 @@ void *S9xProcessSound (void *)
/* If threads in use, this is to loop indefinitely */
/* If not, this will be called by timer */
-#ifdef __linux
+#if defined(__linux) || defined(__NetBSD__)
audio_buf_info info;
if (!Settings.ThreadSound &&

19
snes9x/patches/patch-ah Normal file
View file

@ -0,0 +1,19 @@
$NetBSD: patch-ah,v 1.1.1.1 2005/09/08 10:22:24 leonardschmidt Exp $
--- unzip/unz.h.orig 2004-12-30 22:15:45.000000000 +0000
+++ unzip/unz.h
@@ -11,6 +11,14 @@
---------------------------------------------------------------------------*/
#include "zlib.h"
+/* removed in NetBSD around 2001/01/18 */
+#ifndef OF
+# ifdef STDC
+# define OF(args) args
+# else
+# define OF(args) ()
+# endif
+#endif
/*****************************************/
/* Predefined, Machine-specific Macros */

20
snes9x/patches/patch-ai Normal file
View file

@ -0,0 +1,20 @@
$NetBSD: patch-ai,v 1.1.1.1 2005/09/08 10:22:24 leonardschmidt Exp $
--- unzip/unzip.h.orig 2004-12-30 22:15:45.000000000 +0000
+++ unzip/unzip.h
@@ -49,6 +49,15 @@ extern "C" {
#include "zlib.h"
#endif
+/* removed in NetBSD around 2001/01/18 */
+#ifndef OF
+# ifdef STDC
+# define OF(args) args
+# else
+# define OF(args) ()
+# endif
+#endif
+
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */

14
snes9x/patches/patch-aj Normal file
View file

@ -0,0 +1,14 @@
$NetBSD: patch-aj,v 1.1.1.1 2005/09/08 10:22:24 leonardschmidt Exp $
--- snes9x.cpp.orig 2004-12-30 22:15:47.000000000 +0000
+++ snes9x.cpp
@@ -200,6 +200,9 @@ void S9xUsage ()
-joydevX /dev/jsY Use joystick device /dev/jsY for emulation of gamepad X\n");
S9xMessage (S9X_INFO, S9X_USAGE, "\
-joymapX 0 1 2 3 4 5 6 7 Joystick buttons which should be assigned to gamepad X - A B X Y TL TR Start and Select\n");
+#elif defined(__NetBSD__)
+ S9xMessage (S9X_INFO, S9X_USAGE, "\
+-joymapX 0 1 2 3 4 5 6 7 Joystick buttons which should be assigned to gamepad X - A B X Y TL TR Start and Select\n");
#else
S9xMessage (S9X_INFO, S9X_USAGE, "\
-four or -4 Single standard PC joystick has four buttons\n");

13
snes9x/patches/patch-ak Normal file
View file

@ -0,0 +1,13 @@
$NetBSD: patch-ak,v 1.1.1.1 2005/09/08 10:22:24 leonardschmidt Exp $
--- i386/zsnesc4.asm.orig 2004-12-30 22:15:44.000000000 +0000
+++ i386/zsnesc4.asm
@@ -51,7 +51,7 @@ NEWSYM oamram, times 544 db 0 ; Sprit
SECTION .data
-%ifdef __DJGPP__
+%ifdef _ASM_UNDERBARS
%define ROM _ROM
%define RegRAM _RegRAM
%define S9xInitC4 _S9xInitC4

13
snes9x/patches/patch-al Normal file
View file

@ -0,0 +1,13 @@
$NetBSD: patch-al,v 1.1.1.1 2005/09/08 10:22:24 leonardschmidt Exp $
--- movie.cpp.orig 2004-12-30 22:15:47.000000000 +0000
+++ movie.cpp
@@ -95,7 +95,7 @@
#include <ctype.h>
#include <stdlib.h>
-#if defined(__unix) || defined(__linux) || defined(__sun) || defined(__DJGPP)
+#if defined(__unix) || defined(__linux) || defined(__sun) || defined(__DJGPP) || defined(__NetBSD__)
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>

62
snes9x/patches/patch-am Normal file
View file

@ -0,0 +1,62 @@
$NetBSD: patch-am,v 1.1.1.1 2005/09/08 10:22:24 leonardschmidt Exp $
--- configure.orig 2004-12-30 22:15:48.000000000 +0000
+++ configure
@@ -3063,6 +3063,39 @@ fi
echo "$ac_t""$snes9x_cv_win32_os" 1>&6
+echo $ac_n "checking if the OS is NetBSD""... $ac_c" 1>&6
+echo "configure:3068: checking if the OS is NetBSD" >&5
+if eval "test \"`echo '$''{'snes9x_cv_netbsd_os'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+ cat > conftest.$ac_ext <<EOF
+#line 3074 "configure"
+#include "confdefs.h"
+
+#ifdef __NetBSD__
+/* */
+#else
+#error Not NetBSD.
+#endif
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:3086: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ snes9x_cv_netbsd_os=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ snes9x_cv_netbsd_os=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$snes9x_cv_netbsd_os" 1>&6
# Check whether --with-assembler or --without-assembler was given.
if test "${with_assembler+set}" = set; then
@@ -3183,6 +3216,8 @@ fi
if test yes = "$snes9x_cv_linux_os" -a yes = "$with_joystick"; then
JOYDEFINES=' -DJOYSTICK_SUPPORT'
+elif test yes = "$snes9x_cv_netbsd_os" -a yes = "$with_joystick"; then
+ # gets handled by the Makefile; this is only to prevent confusion
else
with_joystick="no"
fi
@@ -4648,7 +4683,7 @@ else
#line 4649 "configure"
#include "confdefs.h"
-#if defined(__linux) || defined(__sun) || defined(__sgi)
+#if defined(__linux) || defined(__sun) || defined(__sgi) || defined(__NetBSD__)
/* */
#else
#error No sound for this platform

13
snes9x/patches/patch-an Normal file
View file

@ -0,0 +1,13 @@
$NetBSD: patch-an,v 1.1.1.1 2005/09/08 10:22:25 leonardschmidt Exp $
--- i386/sa1struc.h.orig 2004-12-30 22:15:44.000000000 +0000
+++ i386/sa1struc.h
@@ -86,7 +86,7 @@
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
*******************************************************************************/
-#if defined(__DJGCC) || defined(MICROSOFT_C) || defined(_WINDOWS)
+#if defined(__DJGCC) || defined(MICROSOFT_C) || defined(_WINDOWS) || defined(_ASM_UNDERBARS)
#define S9xTraceMessage _S9xTraceMessage
#define S9xGetPPU _S9xGetPPU
#define S9xSetPPU _S9xSetPPU

24
snes9x/patches/patch-ao Normal file
View file

@ -0,0 +1,24 @@
$NetBSD: patch-ao,v 1.1.1.1 2005/09/08 10:22:25 leonardschmidt Exp $
--- fxemu.h.orig 2004-12-30 22:15:45.000000000 +0000
+++ fxemu.h
@@ -89,18 +89,7 @@
#ifndef _FXEMU_H_
#define _FXEMU_H_ 1
-/* Types used by structures and code */
-#ifndef snes9x_types_defined
-#define snes9x_types_defined
-
-typedef unsigned char uint8;
-typedef unsigned short uint16;
-typedef unsigned int uint32;
-typedef unsigned char bool8;
-typedef signed char int8;
-typedef short int16;
-typedef int int32;
-#endif
+#include "port.h"
#ifndef TRUE
#define TRUE 1

28
snes9x/patches/patch-ap Normal file
View file

@ -0,0 +1,28 @@
$NetBSD: patch-ap,v 1.1.1.1 2005/09/08 10:22:25 leonardschmidt Exp $
--- unix/xf86.cpp.orig 2004-12-30 22:15:47.000000000 +0000
+++ unix/xf86.cpp
@@ -92,16 +92,21 @@
Question/comments regarding this file only: maciej@imsa.edu
*/
-#ifdef __linux
+#if defined(__linux) || defined(__NetBSD__)
//#define USE_XF86VIDMODE
+#if defined(__linux)
#include <asm/ioctls.h>
+#endif
+
+#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/time.h>
+#if defined(__linux)
#include <linux/ioctl.h>
+#endif
#include <fcntl.h>
-#include <sys/types.h>
#include <string.h>
#include <ctype.h>

13
snes9x/patches/patch-aq Normal file
View file

@ -0,0 +1,13 @@
$NetBSD: patch-aq,v 1.1.1.1 2005/09/08 10:22:25 leonardschmidt Exp $
--- snaporig.cpp.orig 2004-12-30 22:15:47.000000000 +0000
+++ snaporig.cpp
@@ -93,7 +93,7 @@
#include <ctype.h>
#include <stdlib.h>
-#if defined(__unix) || defined(__linux) || defined(__sun) || defined(__DJGPP)
+#if defined(__unix) || defined(__linux) || defined(__sun) || defined(__DJGPP) || defined(__NetBSD__)
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>