about summary refs log tree commit diff
path: root/pkgs/applications/emulators/pcsxr
diff options
context:
space:
mode:
authorAndersonTorres <torres.anderson.85@protonmail.com>2022-02-15 23:28:16 -0300
committerAndersonTorres <torres.anderson.85@protonmail.com>2022-02-16 01:38:20 -0300
commit8d65e832f0a18f60e2040940c80d96373ac8b88c (patch)
tree3d6ade66b2a81403e3852b80b9e7c660699b6ed6 /pkgs/applications/emulators/pcsxr
parent19574af0af3ffaf7c9e359744ed32556f34536bd (diff)
Move misc/emulators to applications/emulators - part 1
Emulators form a class by themselves. So, they should be moved to applications/.
Diffstat (limited to 'pkgs/applications/emulators/pcsxr')
-rw-r--r--pkgs/applications/emulators/pcsxr/0001-libpcsxcore-fix-build-with-ffmpeg-4.patch76
-rw-r--r--pkgs/applications/emulators/pcsxr/default.nix89
-rw-r--r--pkgs/applications/emulators/pcsxr/uncompress2.patch20
3 files changed, 185 insertions, 0 deletions
diff --git a/pkgs/applications/emulators/pcsxr/0001-libpcsxcore-fix-build-with-ffmpeg-4.patch b/pkgs/applications/emulators/pcsxr/0001-libpcsxcore-fix-build-with-ffmpeg-4.patch
new file mode 100644
index 0000000000000..0edc6281a7efb
--- /dev/null
+++ b/pkgs/applications/emulators/pcsxr/0001-libpcsxcore-fix-build-with-ffmpeg-4.patch
@@ -0,0 +1,76 @@
+From 351be6b3f2ad10d86ec4ae711db5a1067acc592a Mon Sep 17 00:00:00 2001
+From: Zane van Iperen <zane@zanevaniperen.com>
+Date: Sun, 7 Nov 2021 15:17:07 +1000
+Subject: [PATCH] libpcsxcore: fix build with ffmpeg 4
+
+---
+ libpcsxcore/cdriso.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c
+index f89678e..6314482 100644
+--- a/libpcsxcore/cdriso.c
++++ b/libpcsxcore/cdriso.c
+@@ -266,14 +266,14 @@ static int decode_compressed_cdda_track(FILE* outfile, const char* infilepath, s
+ 		}
+ 
+ 		if (!decoded_frame) {
+-			if (!(decoded_frame = avcodec_alloc_frame())) {
++			if (!(decoded_frame = av_frame_alloc())) {
+ 				SysMessage(_(" -> Error allocating audio frame buffer. This track will not be available."));
+ 				avformat_close_input(&inAudioFormat);
+-				avcodec_free_frame(&decoded_frame);
++				av_frame_free(&decoded_frame);
+ 				return 1; // error decoding frame
+ 			}
+ 		} else {
+-			avcodec_get_frame_defaults(decoded_frame);
++			av_frame_unref(decoded_frame);
+ 		}
+ 		len = avcodec_decode_audio4(c, decoded_frame, &got_frame, &avpkt);
+ 		if (len > 0 && got_frame) {
+@@ -285,7 +285,7 @@ static int decode_compressed_cdda_track(FILE* outfile, const char* infilepath, s
+ 			fwrite(decoded_frame->data[0], 1, data_size, outfile);
+ 		}
+ 		av_free_packet(&avpkt);
+-		//avcodec_free_frame(&decoded_frame);
++		//av_frame_free(&decoded_frame);
+ 	} while (moreFrames >= 0); // TODO: check for possible leaks
+ 
+ 	// file will be closed later on, now just flush it
+@@ -294,7 +294,7 @@ static int decode_compressed_cdda_track(FILE* outfile, const char* infilepath, s
+ 	avformat_close_input(&inAudioFormat);
+ 	//avcodec_close(c);
+ 	//av_free(c);
+-	avcodec_free_frame(&decoded_frame);
++	av_frame_free(&decoded_frame);
+ 	return 0;
+ }
+ #endif
+@@ -340,12 +340,12 @@ static int decode_compressed_cdda_track(FILE* outfile, FILE* infile, enum AVCode
+ 	while (avpkt.size > 0) {
+ 		int got_frame = 0;
+ 		if (!decoded_frame) {
+-			if (!(decoded_frame = avcodec_alloc_frame())) {
++			if (!(decoded_frame = av_frame_alloc())) {
+ 				SysPrintf(" -> Error allocating audio frame buffer. Track will not be available.");
+ 				return 1; // error decoding frame
+ 			}
+ 		} else {
+-			avcodec_get_frame_defaults(decoded_frame);
++			av_frame_unref(decoded_frame);
+ 		}
+ 
+ 		len = avcodec_decode_audio4(c, decoded_frame, &got_frame, &avpkt);
+@@ -383,7 +383,7 @@ static int decode_compressed_cdda_track(FILE* outfile, FILE* infile, enum AVCode
+ 
+ 	avcodec_close(c);
+ 	av_free(c);
+-	avcodec_free_frame(&decoded_frame);
++	av_frame_free(&decoded_frame);
+ 	return 0;
+ }
+ #endif
+-- 
+2.31.1
+
diff --git a/pkgs/applications/emulators/pcsxr/default.nix b/pkgs/applications/emulators/pcsxr/default.nix
new file mode 100644
index 0000000000000..e3126efe82db7
--- /dev/null
+++ b/pkgs/applications/emulators/pcsxr/default.nix
@@ -0,0 +1,89 @@
+{ lib, stdenv, fetchurl, autoreconfHook, intltool, pkg-config, gtk3, SDL2, xorg
+, wrapGAppsHook, libcdio, nasm, ffmpeg, file
+, fetchpatch }:
+
+stdenv.mkDerivation rec {
+  pname = "pcsxr";
+  version = "1.9.94";
+
+  # codeplex does not support direct downloading
+  src = fetchurl {
+    url = "mirror://debian/pool/main/p/pcsxr/pcsxr_${version}.orig.tar.xz";
+    sha256 = "0q7nj0z687lmss7sgr93ij6my4dmhkm2nhjvlwx48dn2lxl6ndla";
+  };
+
+  patches = [
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/01_fix-i386-exec-stack.patch";
+      sha256 = "17497wjxd6b92bj458s2769d9bpp68ydbvmfs9gp51yhnq4zl81x";
+    })
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/02_disable-ppc-auto-dynarec.patch";
+      sha256 = "0v8n79z034w6cqdrzhgd9fkdpri42mzvkdjm19x4asz94gg2i2kf";
+    })
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/03_fix-plugin-dir.patch";
+      sha256 = "0vkl0mv6whqaz79kvvvlmlmjpynyq4lh352j3bbxcr0vjqffxvsy";
+    })
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/04_update-homedir-symlinks.patch";
+      sha256 = "18r6n025ybr8fljfsaqm4ap31wp8838j73lrsffi49fkis60dp4j";
+    })
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/05_format-security.patch";
+      sha256 = "03m4kfc9bk5669hf7ji1anild08diliapx634f9cigyxh72jcvni";
+    })
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/06_warnings.patch";
+      sha256 = "0iz3g9ihnhisfgrzma9l74y4lhh57na9h41bmiam1millb796g71";
+    })
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/07_non-linux-ip-addr.patch";
+      sha256 = "14vb9l0l4nzxcymhjjs4q57nmsncmby9qpdr7c19rly5wavm4k77";
+    })
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/08_reproducible.patch";
+      sha256 = "1cx9q59drsk9h6l31097lg4aanaj93ysdz5p88pg9c7wvxk1qz06";
+    })
+
+    ./uncompress2.patch
+    ./0001-libpcsxcore-fix-build-with-ffmpeg-4.patch
+  ];
+
+  nativeBuildInputs = [ autoreconfHook intltool pkg-config wrapGAppsHook ];
+  buildInputs = [
+    gtk3 SDL2 xorg.libXv xorg.libXtst libcdio nasm ffmpeg file
+    xorg.libXxf86vm
+  ];
+
+  dynarecTarget =
+   if stdenv.isx86_64 then "x86_64"
+   else if stdenv.isi686 then "x86"
+   else "no"; #debian patch 2 says ppc doesn't work
+
+  configureFlags = [
+    "--enable-opengl"
+    "--enable-ccdda"
+    "--enable-libcdio"
+    "--enable-dynarec=${dynarecTarget}"
+  ];
+
+  postInstall = ''
+    mkdir -p "$out/share/doc/${pname}-${version}"
+    cp README \
+       AUTHORS \
+       doc/keys.txt \
+       doc/tweaks.txt \
+       ChangeLog.df \
+       ChangeLog \
+       "$out/share/doc/${pname}-${version}"
+  '';
+
+  meta = with lib; {
+    description = "Playstation 1 emulator";
+    homepage = "https://pcsxr.codeplex.com/";
+    maintainers = with maintainers; [ rardiol ];
+    license = licenses.gpl2Plus;
+    platforms = platforms.all;
+  };
+}
diff --git a/pkgs/applications/emulators/pcsxr/uncompress2.patch b/pkgs/applications/emulators/pcsxr/uncompress2.patch
new file mode 100644
index 0000000000000..356868ce7a8b6
--- /dev/null
+++ b/pkgs/applications/emulators/pcsxr/uncompress2.patch
@@ -0,0 +1,20 @@
+--- a/libpcsxcore/cdriso.c
++++ b/libpcsxcore/cdriso.c
+@@ -1219,7 +1219,7 @@
+ 	return ret;
+ }
+ 
+-static int uncompress2(void *out, unsigned long *out_size, void *in, unsigned long in_size)
++static int uncompress3(void *out, unsigned long *out_size, void *in, unsigned long in_size)
+ {
+ 	static z_stream z;
+ 	int ret = 0;
+@@ -1298,7 +1298,7 @@
+ 	if (is_compressed) {
+ 		cdbuffer_size_expect = sizeof(compr_img->buff_raw[0]) << compr_img->block_shift;
+ 		cdbuffer_size = cdbuffer_size_expect;
+-		ret = uncompress2(compr_img->buff_raw[0], &cdbuffer_size, compr_img->buff_compressed, size);
++		ret = uncompress3(compr_img->buff_raw[0], &cdbuffer_size, compr_img->buff_compressed, size);
+ 		if (ret != 0) {
+ 			SysPrintf("uncompress failed with %d for block %d, sector %d\n",
+ 					ret, block, sector);