summaryrefslogtreecommitdiff
path: root/games-emulation/zsnes/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2018-07-14 21:03:06 +0100
committerV3n3RiX <venerix@redcorelinux.org>2018-07-14 21:03:06 +0100
commit8376ef56580626e9c0f796d5b85b53a0a1c7d5f5 (patch)
tree7681bbd4e8b05407772df40a4bf04cbbc8afc3fa /games-emulation/zsnes/files
parent30a9caf154332f12ca60756e1b75d2f0e3e1822d (diff)
gentoo resync : 14.07.2018
Diffstat (limited to 'games-emulation/zsnes/files')
-rw-r--r--games-emulation/zsnes/files/zsnes-1.51-CC-quotes.patch20
-rw-r--r--games-emulation/zsnes/files/zsnes-1.51-arch.patch77
-rw-r--r--games-emulation/zsnes/files/zsnes-1.51-archopt-july-23-update.patch502
-rw-r--r--games-emulation/zsnes/files/zsnes-1.51-buffer.patch85
-rw-r--r--games-emulation/zsnes/files/zsnes-1.51-cross-compile.patch34
-rw-r--r--games-emulation/zsnes/files/zsnes-1.51-depbuild.patch24
-rw-r--r--games-emulation/zsnes/files/zsnes-1.51-gcc43.patch48
-rw-r--r--games-emulation/zsnes/files/zsnes-1.51-gcc47.patch15
-rw-r--r--games-emulation/zsnes/files/zsnes-1.51-libao-thread.patch25
-rw-r--r--games-emulation/zsnes/files/zsnes-1.51-libpng.patch33
-rw-r--r--games-emulation/zsnes/files/zsnes-1.51-libpng15.patch12
-rw-r--r--games-emulation/zsnes/files/zsnes-1.51-stack-align-v2.patch56
-rw-r--r--games-emulation/zsnes/files/zsnes-1.51-stack-align.patch15
13 files changed, 946 insertions, 0 deletions
diff --git a/games-emulation/zsnes/files/zsnes-1.51-CC-quotes.patch b/games-emulation/zsnes/files/zsnes-1.51-CC-quotes.patch
new file mode 100644
index 000000000000..d3230d6d70d5
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-CC-quotes.patch
@@ -0,0 +1,20 @@
+--- src/Makefile.in.orig
++++ src/Makefile.in
+@@ -95,7 +95,7 @@
+ %.o: %.cpp
+ @CXX@ @CXXFLAGS@ -o $@ -c $<
+ %.o %.h: %.psr $(PSR)
+- ./$(PSR) @PSRFLAGS@ -gcc @CC@ -compile -flags "@CFLAGS@ -O1" -cheader $*.h -fname $* $*.o $<
++ ./$(PSR) @PSRFLAGS@ -gcc "@CC@" -compile -flags "@CFLAGS@ -O1" -cheader $*.h -fname $* $*.o $<
+
+ default: main
+ all: main tools--- zsnes_1_51/src/Makefile.in.orig 2009-02-25 18:02:07.000000000 +0100
+@@ -133,7 +133,7 @@
+
+ include makefile.dep
+ makefile.dep: $(TOOL_D)/depbuild Makefile
+- $(TOOL_D)/depbuild @CC@ "@CFLAGS@" @NASMPATH@ "@NFLAGS@" $(Z_OBJS) > makefile.dep
++ $(TOOL_D)/depbuild "@CC@" "@CFLAGS@" @NASMPATH@ "@NFLAGS@" $(Z_OBJS) > makefile.dep
+
+ Makefile: Makefile.in config.status
+ ./config.status
diff --git a/games-emulation/zsnes/files/zsnes-1.51-arch.patch b/games-emulation/zsnes/files/zsnes-1.51-arch.patch
new file mode 100644
index 000000000000..b39549871b7f
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-arch.patch
@@ -0,0 +1,77 @@
+--- a/configure.in.orig
++++ b/configure.in
+@@ -233,72 +233,8 @@
+ debug=no)
+ AC_MSG_CHECKING(if you want gdb friendly executable)
+ AC_MSG_RESULT($debug)
+-if test x$debug = xyes; then
+-dnl - It is easier to debug zsnes with no optimization enabled.
+- ZSNESEXE="zsnesd"
+- PSR_TEMP=""
+- CFLAGS="$CFLAGS -Wall -W -DDEBUG -O0 -fno-omit-frame-pointer -gstabs3"
+- NFLAGS="$NFLAGS -DDEBUG -g -F stabs -s -O0"
+-else
+- ZSNESEXE="zsnes"
+- PSR_TEMP=" rm -f t_\$*.c"
+-
+- CFLAGSBAK="$CFLAGS"
+- AC_ARG_VAR(force_arch, [Force architecture to optimize GCC/G++ for])
+- AC_MSG_CHECKING(which cpu architecture to optimize for)
+- if test x$force_arch != x; then
+- CFLAGS="$CFLAGS -march=$force_arch"
+- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]])],
+- [AC_MSG_RESULT(forcing $force_arch)],
+- [AC_MSG_RESULT($force_arch ??)
+- AC_MSG_WARN(incorrect force_arch parameter)
+- force_arch=""
+- CFLAGS="$CFLAGSBAK"
+- AC_MSG_CHECKING(for autodetected architecture)])
+- else
+- if test x$ARCH_INFO = x; then
+- case x$target in
+- i686-*-*)
+- AC_MSG_RESULT(guessing i686)
+- CFLAGS="$CFLAGS -march=i686"
+- ;;
+- i586-*-*)
+- AC_MSG_RESULT(guessing i586)
+- CFLAGS="$CFLAGS -march=i586"
+- ;;
+- i486-*-*)
+- AC_MSG_RESULT(guessing i486)
+- CFLAGS="$CFLAGS -march=i486"
+- ;;
+- *)
+- AC_MSG_RESULT(guessing i386)
+- CFLAGS="$CFLAGS -march=i386"
+- AC_MSG_WARN([This is not what you want, use --target or force-arch])
+- ;;
+- esac
+- else
+- AC_MSG_RESULT($ARCH_INFO)
+- CFLAGS="$CFLAGS -march=$ARCH_INFO"
+- fi
+- fi
+-
+- AC_ARG_ENABLE(release,
+- [ --enable-release Build ultra-optimized release binary (zsnes)],
+- release=$enableval,
+- release=no)
+- AC_MSG_CHECKING(if you want crazy optimizations)
+- AC_MSG_RESULT($release)
+- if test x$release = xyes; then
+- if test x$force_arch = x; then
+- AC_MSG_WARN([If you intend to distribute this binary, make sure you use force_arch and set to i586 (or whichever CPU Arch you intend for)])
+- fi
+- CFLAGS="$CFLAGS -O3 -fomit-frame-pointer -fprefetch-loop-arrays -fforce-addr $STRIP -D__RELEASE__"
+- NFLAGS="$NFLAGS -O99999999 -D__RELEASE__"
+- else
+- CFLAGS="$CFLAGS -O3 -fomit-frame-pointer $STRIP"
+- NFLAGS="$NFLAGS -O1"
+- fi
+-fi
++ZSNESEXE="zsnes"
++PSR_TEMP=" rm -f t_\$*.c"
+ CXXFLAGS="$CFLAGS -fno-rtti"
+
+ if test x$enable_jma != xno; then
diff --git a/games-emulation/zsnes/files/zsnes-1.51-archopt-july-23-update.patch b/games-emulation/zsnes/files/zsnes-1.51-archopt-july-23-update.patch
new file mode 100644
index 000000000000..b3e466036f22
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-archopt-july-23-update.patch
@@ -0,0 +1,502 @@
+--- a/tools/archopt.c.old
++++ b/tools/archopt.c
+@@ -1,8 +1,30 @@
++/*
++Copyright (C) 2005-2007 Nach, grinvader ( http://www.zsnes.com )
++
++This program is free software; you can redistribute it and/or
++modify it under the terms of the GNU General Public License
++version 2 as published by the Free Software Foundation.
++
++This program is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this program; if not, write to the Free Software
++Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++*/
++
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <ctype.h>
+
++#ifdef _M_X64
++#define __x86_64__
++#endif
++
++#ifdef __GNUC__
+ #ifdef __x86_64__
+ #define cpuid(in, a, b, c, d) asm volatile("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (in));
+ #else
+@@ -13,6 +35,22 @@
+ movl %%ebx,%%edi;\
+ popl %%ebx": "=a" (a), "=D" (b), "=c" (c), "=d" (d) : "a" (in));
+ #endif
++#else
++char cpubuf[256];
++int z_in, z_a, z_b, z_c, z_d;
++void cpuid_run()
++{
++ _asm {
++ mov eax,z_in
++ cpuid
++ mov z_a,eax
++ mov z_b,ebx
++ mov z_c,ecx
++ mov z_d,edx
++ };
++}
++#define cpuid(in, a, b, c, d) z_in = in; cpuid_run(); a = z_a; b = z_b; c = z_c; d = z_d;
++#endif
+
+ char *x86_flags[] =
+ { "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
+@@ -62,6 +100,7 @@
+ {
+ int have = 0x200000;
+ #ifndef __x86_64__
++ #ifdef __GNUC__
+ asm volatile
+ (
+ " pushfl;"
+@@ -76,6 +115,23 @@
+ : "=a" (have)
+ : "c" (have)
+ );
++ #else
++ z_c = have;
++ _asm {
++ mov ecx,z_c
++ pushfd
++ pop eax
++ mov edx,eax
++ xor eax,ecx
++ push eax
++ popfd
++ pushfd
++ pop eax
++ xor eax,edx
++ mov z_a,eax
++ };
++ have = z_a;
++ #endif
+ #endif
+ return(have);
+ }
+@@ -196,238 +252,268 @@
+ cpu = "native";
+ #endif
+ #endif
+-
+- if (!cpu && *cpu_family && *vendor_id)
++ if (!cpu)
+ {
+- if (!strcmp(vendor_id, "AuthenticAMD") || strstr(model_name, "AMD"))
++ if (!cpu && *cpu_family && *vendor_id)
+ {
+- if (strstr(flags, " mmx "))
++ #ifdef __GNUC__
++ if (!strcmp(vendor_id, "AuthenticAMD") || strstr(model_name, "AMD"))
+ {
+- #if __GNUC__ > 2
+- if (strstr(flags, " 3dnow "))
++ if (strstr(flags, " mmx "))
+ {
+- if (strstr(flags, " 3dnowext ") && (atoi(cpu_family) > 5))
++ #if __GNUC__ > 2
++ if (strstr(flags, " 3dnow "))
+ {
+- #if __GNUC__ > 3 || __GNUC_MINOR__ > 0
+- if (strstr(flags, " sse "))
++ if (strstr(flags, " 3dnowext ") && (atoi(cpu_family) > 5))
+ {
+- #if __GNUC__ > 3 || __GNUC_MINOR__ > 3
+- if (strstr(flags, " sse2 ") && strstr(flags, " lm ")) //Need two checks to protect Semprons
++ #if __GNUC__ > 3 || __GNUC_MINOR__ > 0
++ if (strstr(flags, " sse "))
+ {
+- if (strstr(model_name, "Opteron"))
+- {
+- cpu = "opteron";
+- }
+- else if (strstr(model_name, "Athlon(tm) 64")) //Also athlon-fx
++ #if __GNUC__ > 3 || __GNUC_MINOR__ > 3
++ if (strstr(flags, " sse2 ") && strstr(flags, " lm ")) //Need two checks to protect Semprons
+ {
+- cpu = "athlon64";
++ if (strstr(model_name, "Opteron"))
++ {
++ cpu = "opteron";
++ }
++ else if (strstr(model_name, "Athlon(tm) 64")) //Also athlon-fx
++ {
++ cpu = "athlon64";
++ }
++ else
++ {
++ cpu = "k8";
++ }
+ }
+- else
++ #endif
++ if (!cpu)
+ {
+- cpu = "k8";
++ if (strstr(model_name, "Athlon(tm) 4"))
++ {
++ cpu = "athlon-4";
++ }
++ else if (strstr(model_name, "Athlon(tm) MP"))
++ {
++ cpu = "athlon-mp";
++ }
++ else
++ {
++ cpu = "athlon-xp";
++ }
+ }
+ }
++
++ if (!cpu && (atoi(model) > 3))
++ {
++ cpu = "athlon-tbird";
++ }
+ #endif
++
+ if (!cpu)
+ {
+- if (strstr(model_name, "Athlon(tm) 4"))
+- {
+- cpu = "athlon-4";
+- }
+- else if (strstr(model_name, "Athlon(tm) MP"))
+- {
+- cpu = "athlon-mp";
+- }
+- else
+- {
+- cpu = "athlon-xp";
+- }
++ cpu = "athlon";
+ }
+ }
+
+- if (!cpu && (atoi(model) > 3))
+- {
+- cpu = "athlon-tbird";
+- }
+- #endif
+-
++ #if __GNUC__ > 3 || __GNUC_MINOR__ > 0
+ if (!cpu)
+ {
+- cpu = "athlon";
++ int model_num = atoi(model);
++ if ((model_num == 9) || (model_num >= 13))
++ {
++ cpu = "k6-3";
++ }
++ else
++ {
++ cpu = "k6-2";
++ }
+ }
++ #endif
+ }
++ #endif
+
+- #if __GNUC__ > 3 || __GNUC_MINOR__ > 0
+ if (!cpu)
+ {
+- int model_num = atoi(model);
+- if ((model_num == 9) || (model_num >= 13))
+- {
+- cpu = "k6-3";
+- }
+- else
+- {
+- cpu = "k6-2";
+- }
++ cpu = "k6";
+ }
+- #endif
+- }
+- #endif
+-
+- if (!cpu)
+- {
+- cpu = "k6";
+ }
+ }
+- }
+- else if (!strcmp(vendor_id, "GenuineIntel") || strstr(model_name, "Intel"))
+- {
+- #if __GNUC__ > 2
+- if (strstr(flags, " mmx "))
++ else if (!strcmp(vendor_id, "GenuineIntel") || strstr(model_name, "Intel"))
+ {
+- if (strstr(flags, " sse "))
++ #if __GNUC__ > 2
++ if (strstr(flags, " mmx "))
+ {
+- if (strstr(flags, " sse2 "))
++ if (strstr(flags, " sse "))
+ {
+- #if __GNUC__ > 3 || __GNUC_MINOR__ > 2
+- if (strstr(flags, " pni ") && strcmp(cpu_family, "6"))
++ if (strstr(flags, " sse2 "))
+ {
+- if (strstr(flags, " lm "))
++ #if __GNUC__ > 3 || __GNUC_MINOR__ > 2
++ if (strstr(flags, " pni ") && strcmp(cpu_family, "6"))
+ {
+- cpu = "nocona";
++ if (strstr(flags, " lm "))
++ {
++ cpu = "nocona";
++ }
++ else
++ {
++ cpu = "prescott";
++ }
+ }
+- else
++ #endif
++
++ if (!cpu)
+ {
+- cpu = "prescott";
++ if (!strcmp(cpu_family, "6"))
++ {
++ #if __GNUC__ > 3 || __GNUC_MINOR__ > 3
++ cpu = "pentium-m";
++ #else
++ cpu = "pentium3";
++ #endif
++ }
++ else
++ {
++ #if __GNUC__ > 3 || __GNUC_MINOR__ > 3
++ if (strstr(model_name, "Mobile"))
++ {
++ cpu = "pentium4m";
++ }
++ #endif
++
++ if (!cpu)
++ {
++ cpu = "pentium4";
++ }
++ }
+ }
+ }
+- #endif
+-
+- if (!cpu)
++ else
+ {
+- if (!strcmp(cpu_family, "6"))
++ #if __GNUC__ > 3 || __GNUC_MINOR__ > 3
++ if (strstr(model_name, "Mobile"))
+ {
+- #if __GNUC__ > 3 || __GNUC_MINOR__ > 3
+- cpu = "pentium-m";
+- #else
+- cpu = "pentium3";
+- #endif
++ cpu = "pentium3m";
+ }
+- else
+- {
+- #if __GNUC__ > 3 || __GNUC_MINOR__ > 3
+- if (strstr(model_name, "Mobile"))
+- {
+- cpu = "pentium4m";
+- }
+- #endif
++ #endif
+
+- if (!cpu)
+- {
+- cpu = "pentium4";
+- }
++ if (!cpu)
++ {
++ cpu = "pentium3";
+ }
+ }
+ }
+ else
+ {
+- #if __GNUC__ > 3 || __GNUC_MINOR__ > 3
+- if (strstr(model_name, "Mobile"))
++ if (!strcmp(cpu_family, "6"))
+ {
+- cpu = "pentium3m";
++ cpu = "pentium2";
+ }
+- #endif
+-
+- if (!cpu)
++ else
+ {
+- cpu = "pentium3";
++ cpu = "pentium-mmx";
+ }
+ }
+ }
+- else
++ #endif
++
++ if (!cpu)
++ {
++ int family = atoi(cpu_family);
++ if (family > 5)
++ {
++ cpu = "pentiumpro";
++ }
++ else if (family == 5)
++ {
++ cpu = "pentium";
++ }
++ }
++ }
++ #if __GNUC__ > 2
++ #if __GNUC__ > 3 || __GNUC_MINOR__ > 2
++ else if (!strcmp(vendor_id, "CentaurHauls") && strstr(flags, " mmx "))
++ {
++ if (strstr(flags, " 3dnow "))
+ {
+- if (!strcmp(cpu_family, "6"))
++ if (atoi(cpu_family) > 5)
+ {
+- cpu = "pentium2";
++ cpu = "c3";
+ }
+ else
+ {
+- cpu = "pentium-mmx";
++ cpu = "winchip2";
+ }
+ }
++ #if __GNUC__ > 3 || __GNUC_MINOR__ > 3
++ else if (strstr(flags, " sse "))
++ {
++ cpu = "c3-2";
++ }
++ #endif
++
++ if (!cpu)
++ {
++ cpu = "winchip-c6";
++ }
+ }
+ #endif
++ #endif
+
+ if (!cpu)
+ {
+ int family = atoi(cpu_family);
+ if (family > 5)
+ {
+- cpu = "pentiumpro";
++ cpu = "i686";
+ }
+ else if (family == 5)
+ {
+- cpu = "pentium";
++ cpu = "i586";
+ }
+- }
+- }
+- #if __GNUC__ > 2
+- #if __GNUC__ > 3 || __GNUC_MINOR__ > 2
+- else if (!strcmp(vendor_id, "CentaurHauls") && strstr(flags, " mmx "))
+- {
+- if (strstr(flags, " 3dnow "))
+- {
+- if (atoi(cpu_family) > 5)
++ else if (family == 4)
+ {
+- cpu = "c3";
++ cpu = "i486";
+ }
+ else
+ {
+- cpu = "winchip2";
++ cpu = "i386";
+ }
+ }
+- #if __GNUC__ > 3 || __GNUC_MINOR__ > 3
++ #else //MSVC
++ cpu = cpubuf;
++ *cpu = 0;
++
++ if (strstr(flags, " sse2 "))
++ {
++ strcat(cpu, " /arch:SSE2");
++ }
+ else if (strstr(flags, " sse "))
+ {
+- cpu = "c3-2";
++ strcat(cpu, " /arch:SSE");
+ }
+- #endif
+
+- if (!cpu)
++ #ifdef __x86_64__
++ if (strstr(flags, " lm ")) //64 bit
+ {
+- cpu = "winchip-c6";
++ if (!strcmp(vendor_id, "AuthenticAMD") || strstr(model_name, "AMD"))
++ {
++ strcat(cpu, " /favor:AMD64");
++ }
++ else if (!strcmp(vendor_id, "GenuineIntel") || strstr(model_name, "Intel"))
++ {
++ strcat(cpu, " /favor:EM64T");
++ }
+ }
++ #endif
++ #endif
+ }
+- #endif
+- #endif
+-
+- if (!cpu)
++ else
+ {
+- int family = atoi(cpu_family);
+- if (family > 5)
+- {
+- cpu = "i686";
+- }
+- else if (family == 5)
+- {
+- cpu = "i586";
+- }
+- else if (family == 4)
+- {
+- cpu = "i486";
+- }
+- else
+- {
+- cpu = "i386";
+- }
++ puts("Could not open /proc/cpuinfo, and CPUID instruction not available.");
++ return(1);
+ }
+- puts(cpu);
+- }
+- else
+- {
+- puts("Could not open /proc/cpuinfo, and CPUID instruction not available.");
+- return(1);
+ }
++ puts(cpu);
+
+ return(0);
+ }
diff --git a/games-emulation/zsnes/files/zsnes-1.51-buffer.patch b/games-emulation/zsnes/files/zsnes-1.51-buffer.patch
new file mode 100644
index 000000000000..eb463682196d
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-buffer.patch
@@ -0,0 +1,85 @@
+--- src/initc.c.fortify
++++ src/initc.c
+@@ -1464,8 +1464,8 @@
+ clearmem2();
+ }
+
+-extern unsigned char BRRBuffer[32];
+-extern unsigned char echoon0;
++extern unsigned char BRRBuffer[];
++extern unsigned char echoon0[];
+ extern unsigned int PHdspsave;
+ extern unsigned int PHdspsave2;
+ unsigned char echobuf[90000];
+@@ -1479,7 +1479,7 @@
+ memset(vidmemch4, 0, 4096);
+ memset(vidmemch8, 0, 4096);
+ memset(BRRBuffer, 0, PHdspsave);
+- memset(&echoon0, 0, PHdspsave2);
++ memset(echoon0, 0, PHdspsave2);
+ memset(echobuf, 0, 90000);
+ memset(spcBuffera, 0, 65536*4+4096);
+ memset(DSPMem, 0, 256);
+@@ -1822,7 +1822,7 @@
+
+ extern unsigned int nmiprevaddrl, nmiprevaddrh, nmirept, nmiprevline, nmistatus;
+ extern unsigned char spcnumread, yesoutofmemory;
+-extern unsigned char NextLineCache, sramsavedis, sndrot, regsbackup[3019];
++extern unsigned char NextLineCache, sramsavedis, sndrot[], regsbackup[3019];
+ extern unsigned int Voice0Freq, Voice1Freq, Voice2Freq, Voice3Freq;
+ extern unsigned int Voice4Freq, Voice5Freq, Voice6Freq, Voice7Freq;
+ extern unsigned int dspPAdj;
+@@ -2621,7 +2621,7 @@
+ }
+
+ sramsavedis = 0;
+- memcpy(&sndrot, regsbackup, 3019);
++ memcpy(sndrot, regsbackup, 3019);
+
+ if (yesoutofmemory) { asm_call(outofmemfix); }
+ asm_call(GUIDoReset);
+--- src/zstate.c.fortify
++++ src/zstate.c
+@@ -99,15 +99,15 @@
+ copy_func(buffer, &cycpbl, 4);
+ copy_func(buffer, &cycpblt, 4);
+ //SNES PPU Register status
+- copy_func(buffer, &sndrot, 3019);
++ copy_func(buffer, sndrot, 3019);
+ }
+
+ static void copy_spc_data(unsigned char **buffer, void (*copy_func)(unsigned char **, void *, size_t))
+ {
+ //SPC stuff, DSP stuff
+ copy_func(buffer, SPCRAM, PHspcsave);
+- copy_func(buffer, &BRRBuffer, PHdspsave);
+- copy_func(buffer, &DSPMem, sizeof(DSPMem));
++ copy_func(buffer, BRRBuffer, PHdspsave);
++ copy_func(buffer, DSPMem, sizeof(DSPMem));
+ }
+
+ static void copy_extra_data(unsigned char **buffer, void (*copy_func)(unsigned char **, void *, size_t))
+@@ -156,7 +156,7 @@
+ /*
+ if (buffer) //Rewind stuff
+ {
+- copy_func(&buffer, &echoon0, PHdspsave2);
++ copy_func(&buffer, echoon0, PHdspsave2);
+ }
+ */
+ }
+--- src/gblvars.h.fortify
++++ src/gblvars.h
+@@ -33,9 +33,9 @@
+ extern unsigned int SfxR0, *setaramdata, ramsize, *sram, nmiprevaddrh;
+ extern unsigned int tempesi, tempedi, tempedx, tempebp;
+ extern unsigned int SPCMultA, PHnum2writespc7110reg, PHdspsave2;
+-extern unsigned char sndrot, SPCRAM[65472], DSPMem[256], SA1Status, *SA1RAMArea;
+-extern unsigned char DSP1Enable, DSP1COp, prevoamptr, BRRBuffer[32], *romdata;
+-extern unsigned char curcyc, echoon0, spcnumread, NextLineCache, HIRQNextExe;
++extern unsigned char sndrot[], SPCRAM[65472], DSPMem[256], SA1Status, *SA1RAMArea;
++extern unsigned char DSP1Enable, DSP1COp, prevoamptr, BRRBuffer[], *romdata;
++extern unsigned char curcyc, echoon0[], spcnumread, NextLineCache, HIRQNextExe;
+ extern unsigned char vidmemch4[4096], vidmemch8[4096], vidmemch2[4096];
+
+ extern bool C4Enable, SFXEnable, SA1Enable, SPC7110Enable, SETAEnable, DSP4Enable, spcon;
diff --git a/games-emulation/zsnes/files/zsnes-1.51-cross-compile.patch b/games-emulation/zsnes/files/zsnes-1.51-cross-compile.patch
new file mode 100644
index 000000000000..5c412e3e649b
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-cross-compile.patch
@@ -0,0 +1,34 @@
+--- src/acinclude.m4
++++ src/acinclude.m4
+@@ -107,7 +107,7 @@ int main (int argc, char *argv[])
+ with_zlib=yes,
+ with_zlib=no,
+ [AC_MSG_RESULT(cross-compiling)
+- with_zlib=""
++ with_zlib="cross"
+ AC_MSG_WARN(Assuming zlib is available)])
+
+ if test x$with_zlib != x; then
+@@ -116,7 +116,7 @@ fi
+ if test x$with_zlib = xyes; then
+ ZLIB_VERSION=$(<conf.zlibtest)
+ ifelse([$2], , :, [$2])
+-else
++elif test x$with_zlib != xcross; then
+ ZLIB_CFLAGS=""
+ ZLIB_LIBS=""
+ ZLIB_VERSION=""
+--- src/Makefile.in
++++ src/Makefile.in
+@@ -103,8 +103,10 @@ main: makefile.dep $(Z_OBJS)
+ @ZC@ -o @ZSNESEXE@ $(Z_OBJS) @ZCFLAGS@ @LDFLAGS@
+ rm -f version.o
+
++BUILD_CXX ?= g++
++BUILD_CXXFLAGS ?= -O2 -pipe
+ $(PSR): parsegen.cpp
+- @CXX@ @CXXFLAGS@ -o $@ $< -lz
++ $(BUILD_CXX) $(BUILD_CXXFLAGS) -o $@ $< -lz
+
+ TOOLSEXE=$(TOOL_D)/archopt $(TOOL_D)/cutrtype $(TOOL_D)/extraext\
+ $(TOOL_D)/macroll $(TOOL_D)/minwhite $(TOOL_D)/nreplace\
diff --git a/games-emulation/zsnes/files/zsnes-1.51-depbuild.patch b/games-emulation/zsnes/files/zsnes-1.51-depbuild.patch
new file mode 100644
index 000000000000..2dbb5f558a46
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-depbuild.patch
@@ -0,0 +1,24 @@
+--- src/tools/depbuild.cpp.orig
++++ src/tools/depbuild.cpp
+@@ -130,7 +130,20 @@
+ void dependency_calculate_asm(const char *filename)
+ {
+ string command = nasm + " " + nflags + " -M " + filename;
+- system(command.c_str());
++ FILE *fp = popen(command.c_str(), "r");
++ if (fp)
++ {
++ char line[256];
++ while (fgets(line, sizeof(line), fp)) //Process all lines of output
++ {
++ cout << line;
++ }
++ pclose(fp);
++ }
++ else
++ {
++ cerr << "Failed on: " << filename << "\n";
++ }
+ }
+
+ void dependency_calculate_psr(const char *filename)
diff --git a/games-emulation/zsnes/files/zsnes-1.51-gcc43.patch b/games-emulation/zsnes/files/zsnes-1.51-gcc43.patch
new file mode 100644
index 000000000000..4650bc12a7d1
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-gcc43.patch
@@ -0,0 +1,48 @@
+--- src/parsegen.cpp
++++ src/parsegen.cpp
+@@ -31,6 +31,7 @@
+ #include <sstream>
+ #include <set>
+ #include <stack>
++#include <cstring>
+ using namespace std;
+
+ #include <errno.h>
+@@ -1828,7 +1829,7 @@
+ }
+ }
+
+-int main(size_t argc, const char **argv)
++int main(int argc, const char **argv)
+ {
+ const char *cheader_file = 0;
+ bool compile = false;
+--- src/tools/depbuild.cpp
++++ src/tools/depbuild.cpp
+@@ -24,6 +24,7 @@
+ #include <iostream>
+ #include <string>
+ #include <cstdio>
++#include <cstdlib>
+ using namespace std;
+
+ #include "fileutil.h"
+@@ -183,7 +184,7 @@
+ }
+ }
+
+-int main(size_t argc, const char *const *const argv)
++int main(int argc, const char *const *const argv)
+ {
+ if (argc < 5)
+ {
+--- src/tools/strutil.h
++++ src/tools/strutil.h
+@@ -25,6 +25,7 @@
+ #include <string>
+ #include <vector>
+ #include <cctype>
++#include <cstring>
+
+ struct ci_char_traits : public std::char_traits<char>
+ {
diff --git a/games-emulation/zsnes/files/zsnes-1.51-gcc47.patch b/games-emulation/zsnes/files/zsnes-1.51-gcc47.patch
new file mode 100644
index 000000000000..b3250fee679b
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-gcc47.patch
@@ -0,0 +1,15 @@
+Fix compile with gcc47
+Bug #419635
+https://bugs.gentoo.org/show_bug.cgi?id=419635
+Submitted by Nikos Chantziaras
+
+--- src/tools/depbuild.cpp
++++ src/tools/depbuild.cpp
+@@ -25,6 +25,7 @@
+ #include <string>
+ #include <cstdio>
+ #include <cstdlib>
++#include <unistd.h>
+ using namespace std;
+
+ #include "fileutil.h"
diff --git a/games-emulation/zsnes/files/zsnes-1.51-libao-thread.patch b/games-emulation/zsnes/files/zsnes-1.51-libao-thread.patch
new file mode 100644
index 000000000000..1ae0a1467b3e
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-libao-thread.patch
@@ -0,0 +1,25 @@
+--- a/linux/audio.c.old 2007-01-09 20:19:12.000000000 -0500
++++ b/linux/audio.c 2007-12-30 20:33:07.000000000 -0500
+@@ -177,11 +177,7 @@
+ }
+ else
+ {
+- if (pthread_create(&audio_thread, 0, SoundThread_ao, 0))
+- {
+- puts("pthread_create() failed.");
+- }
+- else if (pthread_mutex_init(&audio_mutex, 0))
++ if (pthread_mutex_init(&audio_mutex, 0))
+ {
+ puts("pthread_mutex_init() failed.");
+ }
+@@ -189,6 +185,10 @@
+ {
+ puts("pthread_cond_init() failed.");
+ }
++ else if (pthread_create(&audio_thread, 0, SoundThread_ao, 0))
++ {
++ puts("pthread_create() failed.");
++ }
+ InitSampleControl();
+ }
diff --git a/games-emulation/zsnes/files/zsnes-1.51-libpng.patch b/games-emulation/zsnes/files/zsnes-1.51-libpng.patch
new file mode 100644
index 000000000000..fd974e799e30
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-libpng.patch
@@ -0,0 +1,33 @@
+--- a/acinclude.m4
++++ b/acinclude.m4
+@@ -163,21 +163,21 @@
+ libpng_prefix="")
+
+ min_libpng_version=ifelse([$1], ,1.2.0,$1)
+-tempLIBS="$LIBS"
+-tempCFLAGS="$CFLAGS"
+-if test x$libpng_prefix != x ; then
+- LIBPNG_LIBS="-L$libpng_prefix"
+- LIBPNG_CFLAGS="-I$libpng_prefix"
+-fi
+-LIBPNG_LIBS="$LIBPNG_LIBS -lpng -lm"
+-LIBS="$LIBS $LIBPNG_LIBS"
+-CFLAGS="$CFLAGS $LIBPNG_CFLAGS"
+
+ AC_MSG_CHECKING(for libpng - version >= $min_libpng_version)
+
+ dnl <--- disable for no user choice part #2
+ if test x$enable_libpng != xno; then
+ dnl --->
++ tempLIBS="$LIBS"
++ tempCFLAGS="$CFLAGS"
++ if test x$libpng_prefix != x ; then
++ LIBPNG_LIBS="-L$libpng_prefix"
++ LIBPNG_CFLAGS="-I$libpng_prefix"
++ fi
++ LIBPNG_LIBS="$LIBPNG_LIBS -lpng -lm"
++ LIBS="$LIBS $LIBPNG_LIBS"
++ CFLAGS="$CFLAGS $LIBPNG_CFLAGS"
+
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ #include <png.h>
diff --git a/games-emulation/zsnes/files/zsnes-1.51-libpng15.patch b/games-emulation/zsnes/files/zsnes-1.51-libpng15.patch
new file mode 100644
index 000000000000..b32c30967547
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-libpng15.patch
@@ -0,0 +1,12 @@
+Use existing png_set_IHDR() and stop accessing PNG structure members directly
+
+--- src/zip/zpng.c
++++ src/zip/zpng.c
+@@ -129,7 +129,6 @@
+ png_set_IHDR(png_ptr, info_ptr, width, height, 8,
+ PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
+ PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+- info_ptr->color_type = PNG_COLOR_TYPE_RGB;
+
+ //Allocate an array of scanline pointers
+ row_pointers = (png_bytep*)malloc(height*sizeof(png_bytep));
diff --git a/games-emulation/zsnes/files/zsnes-1.51-stack-align-v2.patch b/games-emulation/zsnes/files/zsnes-1.51-stack-align-v2.patch
new file mode 100644
index 000000000000..35613a953596
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-stack-align-v2.patch
@@ -0,0 +1,56 @@
+zsnes call C initialization code from assembler.
+
+Example backtrace:
+
+ Thread 1 "zsnes" received signal SIGSEGV, Segmentation fault.
+ => 0xf7550275 <+37>: vmovdqa (%esp),%xmm1
+ ...
+ #13 0x5699ef82 in InitSound () at linux/audio.c:336
+ #14 0x569a25af in initwinvideo () at linux/sdllink.c:1080
+ #15 0x5699fc13 in initvideo () at linux/sdllink.c:1298
+ #16 0x56f9d5bc in regptwa ()
+ #17 0x56a34b50 in SA1tableG ()
+ #18 0x56f84788 in selcB800 ()
+ ...
+
+Call to 'initwinvideo' (first C function) looks like that:
+ NEWSYM InitPreGame ; Executes before starting/continuing a game
+ mov byte[pressed+1],2
+ pushad
+ call Start60HZ
+ %ifdef __OPENGL__
+ call drawscreenwin
+ %endif
+ call initwinvideo
+
+Note: pushad / call does not 16-byte maintain stack alignment
+and breaks i386 ABI.
+
+We apply realignment attribute to all functions noticed by users.
+Bug: https://bugs.gentoo.org/503138
+--- src/linux/sdllink.c.old
++++ src/linux/sdllink.c
+@@ -773,11 +773,11 @@ BOOL InitInput()
+ {
+ InitJoystickInput();
+ return TRUE;
+ }
+
+-int startgame()
++int __attribute__((force_align_arg_pointer)) startgame()
+ {
+ static bool ranonce = false;
+ int status;
+
+ if (!ranonce)
+--- a/linux/sdllink.c
++++ b/linux/sdllink.c
+@@ -897,7 +897,7 @@ bool OGLModeCheck()
+ return(cvidmode > 4);
+ }
+
+-void initwinvideo(void)
++void __attribute__((force_align_arg_pointer)) initwinvideo(void)
+ {
+ DWORD newmode = 0;
+
diff --git a/games-emulation/zsnes/files/zsnes-1.51-stack-align.patch b/games-emulation/zsnes/files/zsnes-1.51-stack-align.patch
new file mode 100644
index 000000000000..5dcbf3ad9ebc
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-stack-align.patch
@@ -0,0 +1,15 @@
+--- src/linux/sdllink.c.old
++++ src/linux/sdllink.c
+@@ -773,11 +773,11 @@ BOOL InitInput()
+ {
+ InitJoystickInput();
+ return TRUE;
+ }
+
+-int startgame()
++int __attribute__((force_align_arg_pointer)) startgame()
+ {
+ static bool ranonce = false;
+ int status;
+
+ if (!ranonce)