summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2015-08-08 13:49:04 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2015-08-08 17:38:18 -0700
commit56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch)
tree3f91093cdb475e565ae857f1c5a7fd339e2d781e /games-emulation/zsnes
downloadgentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.bz2
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.zip
proj/gentoo: Initial commit
This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'games-emulation/zsnes')
-rw-r--r--games-emulation/zsnes/Manifest1
-rw-r--r--games-emulation/zsnes/files/zsnes-1.51-CC-quotes.patch20
-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.patch15
-rw-r--r--games-emulation/zsnes/metadata.xml12
-rw-r--r--games-emulation/zsnes/zsnes-1.51-r4.ebuild113
14 files changed, 939 insertions, 0 deletions
diff --git a/games-emulation/zsnes/Manifest b/games-emulation/zsnes/Manifest
new file mode 100644
index 000000000000..f6a4da4e7fda
--- /dev/null
+++ b/games-emulation/zsnes/Manifest
@@ -0,0 +1 @@
+DIST zsnes151src.tar.bz2 1071712 SHA256 eb013f824f5a9814a714cf0daaea3ea68a1c74fd741e5b0979fcb7964236a866 SHA512 2cec9ad7762fc7a257c6b1d3e190b0ed53565dbafe42e1dee9eb182644392b7dd2c57faa846f63cd30ac079e5c05354d26ce0612d20481a1f54d760d62d95353 WHIRLPOOL a023003bcad23dc1da20338dc6adaf6a4061f70f9968a436c5ffeb3263ead85786909b1c2225c0762cd8f0f0a0757c52773326ad2c800f38fcc714f40e4b2162
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-archopt-july-23-update.patch b/games-emulation/zsnes/files/zsnes-1.51-archopt-july-23-update.patch
new file mode 100644
index 000000000000..ba118878a2bd
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-archopt-july-23-update.patch
@@ -0,0 +1,502 @@
+--- tools/archopt.c.old
++++ 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..5f3049b315ed
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-buffer.patch
@@ -0,0 +1,85 @@
+--- zsnes_1_51/src/initc.c.fortify
++++ zsnes_1_51/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);
+--- zsnes_1_51/src/zstate.c.fortify
++++ zsnes_1_51/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);
+ }
+ */
+ }
+--- zsnes_1_51/src/gblvars.h.fortify
++++ zsnes_1_51/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..5823c6aa6ade
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-cross-compile.patch
@@ -0,0 +1,34 @@
+--- a/src/acinclude.m4
++++ b/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=""
+--- a/src/Makefile.in
++++ b/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..e58102415212
--- /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
+
+--- a/src/tools/depbuild.cpp
++++ b/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..880e08c698fe
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-libao-thread.patch
@@ -0,0 +1,25 @@
+--- linux/audio.c.old 2007-01-09 20:19:12.000000000 -0500
++++ 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..4e49054c0972
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-libpng.patch
@@ -0,0 +1,33 @@
+--- acinclude.m4
++++ 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.patch b/games-emulation/zsnes/files/zsnes-1.51-stack-align.patch
new file mode 100644
index 000000000000..e509e0107763
--- /dev/null
+++ b/games-emulation/zsnes/files/zsnes-1.51-stack-align.patch
@@ -0,0 +1,15 @@
+--- zsnes_1_51/src/linux/sdllink.c.old 2014-03-01 04:01:30.351323580 -0500
++++ zsnes_1_51/src/linux/sdllink.c 2014-03-01 04:02:12.249702898 -0500
+@@ -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)
diff --git a/games-emulation/zsnes/metadata.xml b/games-emulation/zsnes/metadata.xml
new file mode 100644
index 000000000000..9be2846979f1
--- /dev/null
+++ b/games-emulation/zsnes/metadata.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <herd>games</herd>
+ <use>
+ <flag name="debug">Enable the builtin debugger</flag>
+ <flag name="pax_kernel">Triggers a paxmarking of the binary</flag>
+ </use>
+ <upstream>
+ <remote-id type="sourceforge">zsnes</remote-id>
+ </upstream>
+</pkgmetadata>
diff --git a/games-emulation/zsnes/zsnes-1.51-r4.ebuild b/games-emulation/zsnes/zsnes-1.51-r4.ebuild
new file mode 100644
index 000000000000..0fedbe9ca3ab
--- /dev/null
+++ b/games-emulation/zsnes/zsnes-1.51-r4.ebuild
@@ -0,0 +1,113 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+inherit eutils autotools flag-o-matic toolchain-funcs multilib pax-utils games
+
+DESCRIPTION="SNES (Super Nintendo) emulator that uses x86 assembly"
+HOMEPAGE="http://www.zsnes.com/ http://ipherswipsite.com/zsnes/"
+SRC_URI="mirror://sourceforge/zsnes/${PN}${PV//./}src.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="-* amd64 x86 ~x86-fbsd ~x86-freebsd ~amd64-linux ~x86-linux"
+IUSE="ao custom-cflags +debug opengl pax_kernel png"
+
+RDEPEND="
+ media-libs/libsdl[sound,video,abi_x86_32(-)]
+ >=sys-libs/zlib-1.2.3-r1[abi_x86_32(-)]
+ ao? ( media-libs/libao[abi_x86_32(-)] )
+ debug? ( sys-libs/ncurses[abi_x86_32(-)] )
+ opengl? ( virtual/opengl[abi_x86_32(-)] )
+ png? ( media-libs/libpng:0[abi_x86_32(-)] )"
+DEPEND="${RDEPEND}
+ dev-lang/nasm
+ debug? ( virtual/pkgconfig )
+ amd64? ( >=sys-apps/portage-2.1 )"
+
+S=${WORKDIR}/${PN}_${PV//./_}/src
+
+src_prepare() {
+ # Fixing compilation without libpng installed
+ # Fix bug #186111
+ # Fix bug #214697
+ # Fix bug #170108
+ # Fix bug #260247
+ # Fix compability with libpng15 wrt #378735
+ # Fix buffer overwrite #257963
+ # Fix gcc47 compile #419635
+ # Fix stack alignment issue #503138
+ epatch \
+ "${FILESDIR}"/${P}-libpng.patch \
+ "${FILESDIR}"/${P}-archopt-july-23-update.patch \
+ "${FILESDIR}"/${P}-gcc43.patch \
+ "${FILESDIR}"/${P}-libao-thread.patch \
+ "${FILESDIR}"/${P}-depbuild.patch \
+ "${FILESDIR}"/${P}-CC-quotes.patch \
+ "${FILESDIR}"/${P}-libpng15.patch \
+ "${FILESDIR}"/${P}-buffer.patch \
+ "${FILESDIR}"/${P}-gcc47.patch \
+ "${FILESDIR}"/${P}-stack-align.patch \
+ "${FILESDIR}"/${P}-cross-compile.patch
+
+ # The sdl detection logic uses AC_PROG_PATH instead of
+ # AC_PROG_TOOL, so force the var to get set the way we
+ # need for things to work correctly.
+ tc-is-cross-compiler && export ac_cv_path_SDL_CONFIG=${CHOST}-sdl-config
+
+ sed -i -e '67i#define OF(x) x' zip/zunzip.h || die
+
+ # Remove hardcoded CFLAGS and LDFLAGS
+ sed -i \
+ -e '/^CFLAGS=.*local/s:-pipe.*:-Wall -I.":' \
+ -e '/^LDFLAGS=.*local/d' \
+ -e '/\w*CFLAGS=.*fomit/s:-O3.*$STRIP::' \
+ -e '/lncurses/s:-lncurses:`pkg-config ncurses --libs`:' \
+ -e '/lcurses/s:-lcurses:`pkg-config ncurses --libs`:' \
+ configure.in || die
+ sed -i \
+ -e 's/configure.in/configure.ac/' \
+ Makefile.in || die
+ mv configure.in configure.ac || die
+ eautoreconf
+}
+
+src_configure() {
+ tc-export CC
+ export BUILD_CXX=$(tc-getBUILD_CXX)
+ use amd64 && multilib_toolchain_setup x86
+ use custom-cflags || strip-flags
+
+ append-flags -U_FORTIFY_SOURCE #257963
+
+ egamesconf \
+ $(use_enable ao libao) \
+ $(use_enable debug debugger) \
+ $(use_enable png libpng) \
+ $(use_enable opengl) \
+ --disable-debug \
+ --disable-cpucheck \
+ --enable-release \
+ force_arch=no
+}
+
+src_compile() {
+ emake makefile.dep
+ emake
+}
+
+src_install() {
+ dogamesbin zsnes
+ if use pax_kernel; then
+ pax-mark m "${D}""${GAMES_BINDIR}"/zsnes || die
+ fi
+ newman linux/zsnes.1 zsnes.6
+ dodoc \
+ ../docs/{readme.1st,authors.txt,srcinfo.txt,stdards.txt,support.txt,thanks.txt,todo.txt,README.LINUX} \
+ ../docs/readme.txt/*
+ dohtml -r ../docs/readme.htm/*
+ make_desktop_entry zsnes ZSNES
+ newicon icons/48x48x32.png ${PN}.png
+ prepgamesdirs
+}