summary refs log tree commit diff
path: root/pkgs/misc/emulators/fakenes
diff options
context:
space:
mode:
authorLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2011-03-25 22:15:48 +0000
committerLluís Batlle i Rossell <viric@vicerveza.homeunix.net>2011-03-25 22:15:48 +0000
commitef57b57b929057bae4ab5711cbf799a241018967 (patch)
tree230c7eb221c433f83eeefc0d56c69aeda7b58a80 /pkgs/misc/emulators/fakenes
parent9eb80e4f944a8c9d3ef5ab43542565d2cdef96ab (diff)
downloadnixpkgs-ef57b57b929057bae4ab5711cbf799a241018967.tar
nixpkgs-ef57b57b929057bae4ab5711cbf799a241018967.tar.gz
nixpkgs-ef57b57b929057bae4ab5711cbf799a241018967.tar.bz2
nixpkgs-ef57b57b929057bae4ab5711cbf799a241018967.tar.lz
nixpkgs-ef57b57b929057bae4ab5711cbf799a241018967.tar.xz
nixpkgs-ef57b57b929057bae4ab5711cbf799a241018967.tar.zst
nixpkgs-ef57b57b929057bae4ab5711cbf799a241018967.zip
Adding two NES emulators.
Because of them, I made allegro build the allegrogl library.
I also added the HawkNL library.


svn path=/nixpkgs/trunk/; revision=26517
Diffstat (limited to 'pkgs/misc/emulators/fakenes')
-rw-r--r--pkgs/misc/emulators/fakenes/build.patch84
-rw-r--r--pkgs/misc/emulators/fakenes/default.nix28
2 files changed, 112 insertions, 0 deletions
diff --git a/pkgs/misc/emulators/fakenes/build.patch b/pkgs/misc/emulators/fakenes/build.patch
new file mode 100644
index 00000000000..90799d977a1
--- /dev/null
+++ b/pkgs/misc/emulators/fakenes/build.patch
@@ -0,0 +1,84 @@
+diff --git a/build/openal.cbd b/build/openal.cbd
+index d18e62d..74af061 100644
+--- a/build/openal.cbd
++++ b/build/openal.cbd
+@@ -23,7 +23,7 @@ CFLAGS += ' -DUSE_OPENAL'
+ # --
+ 
+ do ifplat unix
+-   LDFLAGS += ' `openal-config --libs`'
++   LDFLAGS += ' -lopenal'
+ else
+    LDFLAGS += ' -lOpenAL32'
+ done
+diff --git a/build/alleggl.cbd b/build/alleggl.cbd
+index e2708ff..e826371 100644
+--- a/build/alleggl.cbd
++++ b/build/alleggl.cbd
+@@ -22,7 +22,7 @@ CFLAGS += ' -DUSE_ALLEGROGL'
+ 
+ # --
+ 
+-LIBAGL = agl
++LIBAGL = alleggl
+ 
+ ifopt debug LIBAGL = 'agld'
+
+diff --git a/src/apu.cpp b/src/apu.cpp
+index af59f1c..893a798 100644
+--- a/src/apu.cpp
++++ b/src/apu.cpp
+@@ -1930,7 +1930,7 @@ static void amplify(real& sample)
+          gain -= releaseRate;
+       }
+ 
+-      real output = (1.0 / max(gain, EPSILON));
++      real output = (1.0 / MAX(gain, EPSILON));
+       output = fixf(output, apu_agc_gain_floor, apu_agc_gain_ceiling);
+       sample *= output;
+    }
+diff --git a/src/audio.cpp b/src/audio.cpp
+index b9650dc..c21c05e 100644
+--- a/src/audio.cpp
++++ b/src/audio.cpp
+@@ -7,6 +7,7 @@
+    You must read and accept the license prior to use. */
+ 
+ #include <allegro.h>
++#include <cstdio>
+ #include <cstdlib>
+ #include <cstring>
+ #include <vector>
+@@ -234,7 +235,7 @@ void audio_update(void)
+          const unsigned queuedFrames = (audioQueue.size() / audio_channels);
+          if(queuedFrames > 0) {
+             // Determine how many frames we want to make room for.
+-            const unsigned framesToAdd = min(queuedFrames, audio_buffer_size_frames);
++            const unsigned framesToAdd = MIN(queuedFrames, audio_buffer_size_frames);
+             // Make room for the frames in the buffer.
+             const unsigned framesToMove = (audioBufferedFrames - framesToAdd);
+             if(framesToMove > 0) {
+@@ -258,7 +259,7 @@ void audio_update(void)
+          // Determine how many frames are available in the buffer.
+          const unsigned bufferableFrames = (audio_buffer_size_frames - audioBufferedFrames);
+          // Determine the number of frames to copy to the buffer.
+-         const unsigned framesToCopy = min(queuedFrames, bufferableFrames);
++         const unsigned framesToCopy = MIN(queuedFrames, bufferableFrames);
+ 
+          // Copy frames to the buffer.
+          for(unsigned frame = 0; frame < framesToCopy; frame++) {
+diff --git a/src/include/common.h b/src/include/common.h
+index be28795..e2d21d1 100644
+--- a/src/include/common.h
++++ b/src/include/common.h
+@@ -41,8 +41,10 @@ extern "C" {
+ #define true   TRUE
+ #define false  FALSE
+ 
++/*
+ #define min(x,y)   MIN((x),(y))
+ #define max(x,y)   MAX((x),(y))
++*/
+ 
+ #define true_or_false(x)   ((x) ? true : false)
+ 
diff --git a/pkgs/misc/emulators/fakenes/default.nix b/pkgs/misc/emulators/fakenes/default.nix
new file mode 100644
index 00000000000..62ecb6e4156
--- /dev/null
+++ b/pkgs/misc/emulators/fakenes/default.nix
@@ -0,0 +1,28 @@
+{stdenv, fetchurl, allegro, openal, mesa, zlib, hawknl, freeglut, libX11,
+  libXxf86vm, libXcursor, libXpm }:
+
+stdenv.mkDerivation { 
+  name = "fakenes-0.5.9b3";
+  src = fetchurl {
+    url = mirror://sourceforge/fakenes/fakenes-0.5.9-beta3.tar.gz;
+    sha256 = "026h67s4pzc1vma59pmzk02iy379255qbai2q74wln9bxqcpniy4";
+  };
+
+  buildInputs = [ allegro openal mesa zlib hawknl freeglut libX11
+    libXxf86vm libXcursor libXpm ];
+
+  installPhase = ''
+    ensureDir $out/bin
+    cp fakenes $out/bin
+  '';
+
+  NIX_LDFLAGS = "-lX11 -lXxf86vm -lXcursor -lXpm"; 
+
+  patches = [ ./build.patch ];
+
+  meta = {
+    homepage = http://fakenes.sourceforge.net/;
+    license = "GPLv2+";
+    description = "Portable Open Source NES Emulator";
+  };
+}