Bug 61529 - Duke Nukem 3D crashes on PPC
Bug#: 61529 Product:  Gentoo Linux Version: unspecified Platform: PPC
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: games@gentoo.org Reported By: mat@esi.com.pl
Component: Games
URL:  https://bugzilla.icculus.org/show_bug.cgi?id=1914
Summary: Duke Nukem 3D crashes on PPC
Keywords:  
Status Whiteboard: 
Opened: 2004-08-24 09:48 0000
Description:   Opened: 2004-08-24 09:48 0000
After emerging Duke Nukem 3D (duke3d-20040817.ebuild) I found out that while
it compiles fine it refuses to start with the message "Not enough memory for
file grouping system".

Reproducible: Always
Steps to Reproduce:
1.
2.
3.




After some digging I found that there is an endianness problem - game does 
necessary byte-swapping only on Mac. Below is the patch that solved the 
problem for me. 
 
------------------------------ duke3d-20040817-endian_patch  
--- duke3d/source/buildengine/platform.h        2003-08-07 
12:06:17.000000000+0200 
+++ duke3d.new/source/buildengine/platform.h    2004-08-24 
18:35:05.292291088+0200 
@@ -5,6 +5,7 @@ 
 #include "win32_compat.h" 
 #elif (defined PLATFORM_UNIX) 
 #include "unix_compat.h" 
+#include <endian.h> 
 #elif (defined PLATFORM_DOS) 
 #include "doscmpat.h" 
 #else 
@@ -60,9 +61,15 @@ 
 #define BUILDSWAP_INTEL16(x) _swap16(x) 
 #define BUILDSWAP_INTEL32(x) _swap32(x) 
 #else 
+#if __BYTE_ORDER == __LITTLE_ENDIAN 
 #define PLATFORM_LITTLEENDIAN 1 
 #define BUILDSWAP_INTEL16(x) (x) 
 #define BUILDSWAP_INTEL32(x) (x) 
+#else 
+#define PLATFORM_BIGENDIAN 1 
+#define BUILDSWAP_INTEL16(x) _swap16(x) 
+#define BUILDSWAP_INTEL32(x) _swap32(x) 
+#endif 
 #endif 
 
 extern int has_altivec;  /* PowerPC-specific. */ 
-----------------------------------------------------------

------- Comment #1 From Maciej J. Woloszyk 2004-08-24 09:58:59 0000 -------
Created an attachment (id=38105) [details]
duke3d-20040817-endian_patch

------- Comment #2 From Chris Gianelloni (RETIRED) 2004-08-24 10:12:28 0000 -------
Just curious, but have you checked to see if this has been fixed upstream?

------- Comment #3 From Maciej J. Woloszyk 2004-08-24 10:14:24 0000 -------
Nope. I just wanted to see it running on my machine _now_ ;)

------- Comment #4 From Lars Weiler (RETIRED) 2004-08-24 21:27:39 0000 -------
Curious, the homepage just describes a Linux/x86 and a Mac OS X/ppc port.  No
Linux/ppc port.  So I'm not sure if it will run on Linux/ppc.

dholm, you set the ~ppc keyword.  Tell us more ;-)

------- Comment #5 From Maciej J. Woloszyk 2004-08-24 23:15:27 0000 -------
Well... Without the change I did it compiled but crashed (wrong byte swapping
due to wrong endianness). After the change it starts fine, plays the intros
etc. Then I started the game - it worked too but not fast enough as for my
liking so I played for maybe two minutes and quited. So for me - now it is
properly marked as ~ppc as it does run to some extent.

------- Comment #6 From SpanKY 2004-08-26 19:44:36 0000 -------
awesome, added to cvs, thanks ... also e-mailed it upstream

------- Comment #7 From Ryan C. Gordon 2004-08-26 23:10:45 0000 -------
(This is in the upstream CVS now. Thanks for the patch!)

--ryan.