[SCM] Emulator of the Super Nintendo Entertainment System (TM) branch, fortify, updated. debian/1.510+bz2-4-11-g8183446

Etienne Millon me at emillon.org
Mon Sep 10 09:30:32 UTC 2012


The following commit has been merged in the fortify branch:
commit 7c532dc9ceb0e7705a052d98ac3981f9203d6d0b
Author: Etienne Millon <me at emillon.org>
Date:   Sun Sep 9 21:26:51 2012 +0200

    Pick patch for #687107

diff --git a/debian/changelog b/debian/changelog
index 03d4c86..cd55803 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,11 +1,16 @@
 zsnes (1.510+bz2-5) UNRELEASED; urgency=low
 
+  [ Fabian Greffrath ]
   * 0002-replace_crc32.patch: Removed, not actually needed at all.
   * 0013-Fix-sound-with-libao.patch: Replace with the actual patch from
     upstream SVN.
   * 0014-Initialize-driver_format.matrix-with-NULL.patch: Only keep the
     memset() part as discussed with upstream author Nach on the ZSNES board.
 
+  [ Etienne Millon ]
+  * Fix crashes on resume : use int64s instead of floats in sem_GetTicks().
+    Thanks to Ian Munsie. (Closes: #687107)
+
  -- Fabian Greffrath <fabian+debian at greffrath.com>  Wed, 18 Jul 2012 11:04:28 +0200
 
 zsnes (1.510+bz2-4) unstable; urgency=low
diff --git a/debian/patches/series b/debian/patches/series
index 3972a5e..ae0e13f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -11,3 +11,4 @@
 0012-Fix-build-with-gcc-4.7.patch
 0013-Fix-sound-with-libao.patch
 0014-Initialize-driver_format.matrix-with-NULL.patch
+zsnes-linux-resume-freeze-fix.patch
diff --git a/debian/patches/zsnes-linux-resume-freeze-fix.patch b/debian/patches/zsnes-linux-resume-freeze-fix.patch
new file mode 100644
index 0000000..0dd1b95
--- /dev/null
+++ b/debian/patches/zsnes-linux-resume-freeze-fix.patch
@@ -0,0 +1,130 @@
+>From 2c29409f6c7dd7cbacd7027b4afcc08546fa7a66 Mon Sep 17 00:00:00 2001
+From: Ian Munsie <darkstarsword at gmail.com>
+Date: Mon, 10 Sep 2012 03:51:13 +1000
+Subject: [PATCH] Replace floating point arithmetic causing freeze with 64bit
+ integer arithmetic
+
+It seems that sem_GetTicks sometimes returns NAN. If this happens when
+resuming the game (i.e. from Start60HZ), than the start variable can be
+set to NAN, which causes this test in CheckTimers to never succeed:
+while ((end - start) >= update_ticks_pc)
+
+So it never runs Game60hzcall and therefore appears to freeze.
+
+Using gdb to change start to a real number less than end allows zsnes to
+continue.
+
+See this forum post for more details:
+http://board.zsnes.com/phpBB3/viewtopic.php?f=3&t=2337&p=225071#p225071
+
+This patch changes it to use a 64bit integer instead of floating point
+arithmetic to avoid hitting these cases.
+
+Also, remove the unused start2, end2, and update_ticks_pc2 variables.
+
+Signed-off-by: Ian Munsie <darkstarsword at gmail.com>
+---
+ src/linux/sdllink.c |   35 ++++++++++++-----------------------
+ 1 file changed, 12 insertions(+), 23 deletions(-)
+
+diff --git a/src/linux/sdllink.c b/src/linux/sdllink.c
+index 4274c9d..eece048 100644
+--- a/src/linux/sdllink.c
++++ b/src/linux/sdllink.c
+@@ -111,23 +111,23 @@ static BYTE IsActivated = 1;
+ 
+ /* TIMER VARIABLES/MACROS */
+ // millisecond per world update
+-#define UPDATE_TICKS_GAME (1000.0/59.948743718592964824120603015060)
+-#define UPDATE_TICKS_GAMEPAL (20.0)
+-#define UPDATE_TICKS_GUI (1000.0/36.0)
+-#define UPDATE_TICKS_UDP (1000.0/60.0)
++#define UPDATE_TICKS_GAME (1000000.0/59.948743718592964824120603015060)
++#define UPDATE_TICKS_GAMEPAL (20000)
++#define UPDATE_TICKS_GUI (1000000/36)
++#define UPDATE_TICKS_UDP (1000000/60)
+ 
+ int T60HZEnabled = 0;
+ int T36HZEnabled = 0;
+-float end, end2;
+-float start, start2;
+-float update_ticks_pc, update_ticks_pc2;
++unsigned long long end;
++unsigned long long start;
++unsigned long long update_ticks_pc;
+ 
+ // Used for semaphore code
+ static SDL_sem *sem_frames = NULL;
+ static struct timeval sem_start;
+ void sem_sleep_rdy(void);
+ void sem_sleep_die(void);
+-float sem_GetTicks(void);
++unsigned long long sem_GetTicks(void);
+ 
+ extern unsigned char romispal;
+ 
+@@ -830,7 +830,6 @@ int startgame()
+ 
+ void Start60HZ(void)
+ {
+-  update_ticks_pc2 = UPDATE_TICKS_UDP;
+   if (romispal == 1)
+   {
+     update_ticks_pc = UPDATE_TICKS_GAMEPAL;
+@@ -842,7 +841,6 @@ void Start60HZ(void)
+ 
+   // Restore timer data from semaphore data
+   start = sem_GetTicks();
+-  start2 = sem_GetTicks();
+   T36HZEnabled = 0;
+   T60HZEnabled = 1;
+ }
+@@ -854,12 +852,10 @@ void Stop60HZ(void)
+ 
+ void Start36HZ(void)
+ {
+-  update_ticks_pc2 = UPDATE_TICKS_UDP;
+   update_ticks_pc = UPDATE_TICKS_GUI;
+ 
+   // Restore timer data from semaphore data
+   start = sem_GetTicks();
+-  start2 = sem_GetTicks();
+   T60HZEnabled = 0;
+   T36HZEnabled = 1;
+ }
+@@ -1097,14 +1093,6 @@ void initwinvideo(void)
+ 
+ void CheckTimers(void)
+ {
+-  //QueryPerformanceCounter((LARGE_INTEGER*)&end2);
+-  end2 = sem_GetTicks();
+-
+-  while ((end2 - start2) >= update_ticks_pc2)
+-  {
+-    start2 += update_ticks_pc2;
+-  }
+-
+   if (T60HZEnabled)
+   {
+     //QueryPerformanceCounter((LARGE_INTEGER*)&end);
+@@ -1306,13 +1294,14 @@ void __attribute__ ((stdcall, constructor)) sem_StartTicks()
+   gettimeofday(&sem_start, NULL);
+ }
+ 
+-float sem_GetTicks()
++unsigned long long sem_GetTicks()
+ {
+   struct timeval now;
+-  float ticks;
++  unsigned long long ticks;
+ 
+   gettimeofday(&now, NULL);
+-  ticks=((float)(now.tv_sec-sem_start.tv_sec))*1000.f+((float)(now.tv_usec-sem_start.tv_usec))*.001f;
++  ticks = (now.tv_sec - sem_start.tv_sec) * 1000000 +
++	  (now.tv_usec - sem_start.tv_usec);
+   return(ticks);
+ }
+ 
+-- 
+1.7.10.4
+

-- 
Emulator of the Super Nintendo Entertainment System (TM)



More information about the Pkg-games-commits mailing list