rpms/nogravity/devel nogravity--64-bit.patch, NONE, 1.1 nogravity--Makefile.am, NONE, 1.1 nogravity--README.patch, NONE, 1.1 nogravity--bootstrap, NONE, 1.1 nogravity--bufer-overflows.patch, NONE, 1.1 nogravity--configure.in, NONE, 1.1 nogravity--cvs.patch, NONE, 1.1 nogravity--fixed_path_to_game_data.diff, NONE, 1.1 nogravity--fullscreen_as_option.patch, NONE, 1.1 nogravity--openal.patch, NONE, 1.1 nogravity--snd_sdlmixer_c-powerpc-fix.diff, NONE, 1.1 nogravity.desktop, NONE, 1.1 nogravity.png, NONE, 1.1 nogravity.sh, NONE, 1.1 nogravity.spec, NONE, 1.1 .cvsignore, 1.1, 1.2 sources, 1.1, 1.2

Hans de Goede (jwrdegoede) fedora-extras-commits at redhat.com
Wed Jan 30 10:05:54 UTC 2008


Author: jwrdegoede

Update of /cvs/extras/rpms/nogravity/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv14331/devel

Modified Files:
	.cvsignore sources 
Added Files:
	nogravity--64-bit.patch nogravity--Makefile.am 
	nogravity--README.patch nogravity--bootstrap 
	nogravity--bufer-overflows.patch nogravity--configure.in 
	nogravity--cvs.patch nogravity--fixed_path_to_game_data.diff 
	nogravity--fullscreen_as_option.patch nogravity--openal.patch 
	nogravity--snd_sdlmixer_c-powerpc-fix.diff nogravity.desktop 
	nogravity.png nogravity.sh nogravity.spec 
Log Message:
initial nogravity import


nogravity--64-bit.patch:

--- NEW FILE nogravity--64-bit.patch ---
diff -ur nogravity-2.00/rlx32/include/gx_flc.h nogravity-2.00.new/rlx32/include/gx_flc.h
--- nogravity-2.00/rlx32/include/gx_flc.h	2005-02-24 20:16:20.000000000 +0100
+++ nogravity-2.00.new/rlx32/include/gx_flc.h	2007-11-17 22:57:25.000000000 +0100
@@ -66,7 +66,7 @@
     int32_t        frame1;
     int32_t        frame2;
     char        reserved3[40];
-}FLC_FileHeader;  // FIXME : pas tres align‚
+} __attribute__((__packed__)) FLC_FileHeader;
 
 typedef union {
     FLC_FileHeader Struct;
@@ -83,7 +83,7 @@
 
     GXSPRITE      bitmap;
     u_int32_t       start;
-    u_int32_t       start_buf;
+    uintptr_t       start_buf;
     u_int32_t       LastTime;
     u_int16_t      CurrentFrame;
     u_int16_t      MaximumFrame;
diff -ur nogravity-2.00/rlx32/include/v3xcoll.h nogravity-2.00.new/rlx32/include/v3xcoll.h
--- nogravity-2.00/rlx32/include/v3xcoll.h	2005-02-24 20:16:18.000000000 +0100
+++ nogravity-2.00.new/rlx32/include/v3xcoll.h	2007-11-20 10:54:09.000000000 +0100
@@ -68,8 +68,12 @@
     u_int16_t	      *sectorList;// Sector list
     u_int32_t	       maxsectors; // maxSectors
     V3XMESH	      *mesh_ref;
+/* No padding when using 64 bit pointers to make this the same size as
+   V3XCL_SPHERE and V3XCL_BOX. We are 3 ints bigger due to the 3 pointers,
+   and one additional int to align the last pointer on a 64 bit boundary */
+#ifndef __LP64__
     u_int32_t              pad[4];    // pad
-
+#endif
 }V3XCL_MESH;
 
 typedef struct _v3x_cl_sphere{                  // 64b
diff -ur nogravity-2.00/rlx32/include/v3xdefs.h nogravity-2.00.new/rlx32/include/v3xdefs.h
--- nogravity-2.00/rlx32/include/v3xdefs.h	2005-02-24 20:16:22.000000000 +0100
+++ nogravity-2.00.new/rlx32/include/v3xdefs.h	2007-11-20 10:43:29.000000000 +0100
@@ -327,6 +327,8 @@
     u_int16_t      	 	selfIllumine;   // Self illumination value (0..255)
 
     V3XSCALAR   	 	scale;          // Uniform scaling
+    /* Note an int32 of padding is added here by the compiler when compiling
+       for a platform with 64 bit pointers */
     union   
 	{
         V3XSCALAR	*	shade;
@@ -334,7 +336,6 @@
     };
     V3XSCALAR	 		radius;
     u_int32_t        	pad;        // Pad
-
 }V3XMESH;
 
 /*
@@ -354,6 +355,8 @@
     V3XSCALAR    	 	range;          // Light range
     V3XSCALAR    	 	falloff;       // Spot falloff size
     rgb32_t				color;          // RGBA color
+    /* Note an int32 of padding is added here by the compiler when compiling
+       for a platform with 64 bit pointers */
     union {
 		 V3XMATERIAL 		*	material;       // Material
 		struct _v3xsprite 	*	flare;
@@ -361,6 +364,9 @@
     V3XSCALAR			flaresize;
 	rgb32_t				specular;
 	void			*	reserved[2];
+#ifdef __LP64__
+	u_int32_t alignTK_lp64[2];
+#endif    
 
     V3XKEY      		Tk;
 
@@ -369,7 +375,11 @@
     u_int8_t			alpha;
     u_int8_t       		status;
     u_int32_t			Timer, TimeOn, TimeOff;
+#ifndef __LP64__
     u_int32_t       	pad2[3];
+#else
+    u_int32_t       	pad2[5];
+#endif
 }V3XLIGHT;
 
 /*
@@ -380,9 +390,16 @@
     u_int32_t         matrix_Method;
     V3XVECTOR     transposed;      // Internal
     V3XSCALAR      focal;           // focal value
+#ifdef __LP64__
+    u_int32_t alignTK_lp64[6];
+#endif
     V3XMATRIX     M;               // Matrix 
     V3XKEY        Tk;              // Keyframe informations 22 q
+#ifndef __LP64__
     u_int32_t         pad[7];
+#else
+    u_int32_t         pad[9];
+#endif
 }V3XCAMERA;
 
 /*
diff -ur nogravity-2.00/rlx32/include/v3xscene.h nogravity-2.00.new/rlx32/include/v3xscene.h
--- nogravity-2.00/rlx32/include/v3xscene.h	2005-02-24 20:16:16.000000000 +0100
+++ nogravity-2.00.new/rlx32/include/v3xscene.h	2007-11-19 20:00:27.000000000 +0100
@@ -112,17 +112,31 @@
 
 typedef struct _v3x_dummy{
  u_int32_t pad[6];
+#ifdef __LP64__
+ u_int32_t alignTK_lp64[6];
+#endif
  V3XMATRIX matrix;
  V3XKEY Tk;
- u_int32_t pad0[3];
+#ifndef __LP64__
+ u_int32_t pad0[3+4];
+#else
+ u_int32_t pad0[3+4+2];
+#endif
 }V3XDUMMY;
 
 
 typedef struct _v3x_node{
  u_int32_t pad[6];
+#ifdef __LP64__
+ u_int32_t alignTK_lp64[6];
+#endif
  V3XMATRIX matrix;
  V3XKEY Tk;
+#ifndef __LP64__
  u_int32_t pad0[3+4];
+#else
+ u_int32_t pad0[3+4+2];
+#endif
 }V3XNODE;
 
 
diff -ur nogravity-2.00/rlx32/src/gx_csp.c nogravity-2.00.new/rlx32/src/gx_csp.c
--- nogravity-2.00/rlx32/src/gx_csp.c	2005-06-17 21:59:34.000000000 +0200
+++ nogravity-2.00.new/rlx32/src/gx_csp.c	2007-11-19 22:14:01.000000000 +0100
@@ -443,7 +443,7 @@
 {
     u_int32_t sz = lx*ly, 
     sz2 = sz*bpp, 
-    ok = (((u_int32_t)MM_heap.PreviousAddress==(u_int32_t)sp->data)&&(MM_heap.active));
+    ok = (((uintptr_t)MM_heap.PreviousAddress==(uintptr_t)sp->data)&&(MM_heap.active));
     u_int8_t *tmp;
     tmp = (u_int8_t *)MM_heap.malloc(sz2);
     IMG_stretch(sp->data, tmp, sp->LY, ly, sp->LX, lx, bpp);
diff -ur nogravity-2.00/rlx32/src/gx_flc.c nogravity-2.00.new/rlx32/src/gx_flc.c
--- nogravity-2.00/rlx32/src/gx_flc.c	2005-06-17 21:59:34.000000000 +0200
+++ nogravity-2.00.new/rlx32/src/gx_flc.c	2007-11-17 22:58:00.000000000 +0100
@@ -341,7 +341,7 @@
     if (pAnim->ReadMode==FLI_USEMEMORY)
     {
         FIO_cur->fread(pAnim->fileBuffer, sizeof(u_int8_t), pAnim->Header.Struct.size-128L-pAnim->start, pAnim->fli_stream);
-        pAnim->start_buf = (u_int32_t)pAnim->fileBuffer;
+        pAnim->start_buf = (uintptr_t)pAnim->fileBuffer;
         FIO_cur->fclose(pAnim->fli_stream);
         pAnim->fli_stream = NULL;
     }
diff -ur nogravity-2.00/rlx32/src/systools.c nogravity-2.00.new/rlx32/src/systools.c
--- nogravity-2.00/rlx32/src/systools.c	2005-02-24 20:15:02.000000000 +0100
+++ nogravity-2.00.new/rlx32/src/systools.c	2007-11-19 22:12:57.000000000 +0100
@@ -313,7 +313,7 @@
     u_int8_t *v = MM_heap.heapAddress     + MM_heap.CurrentAddress;
     MM_heap.PreviousAddress = MM_heap.CurrentAddress;
     {
-        int32_t off = ((u_int32_t)v+size)&31;
+        int32_t off = ((uintptr_t)v+size)&31;
         if (off) size+=32-off;           // Alignement sur 32 octets
     }
     MM_heap.CurrentAddress+=size;
diff -ur nogravity-2.00/rlx32/src/v3xscen2.c nogravity-2.00.new/rlx32/src/v3xscen2.c
--- nogravity-2.00/rlx32/src/v3xscen2.c	2005-06-17 21:59:34.000000000 +0200
+++ nogravity-2.00.new/rlx32/src/v3xscen2.c	2007-11-20 14:03:57.000000000 +0100
@@ -1049,13 +1049,45 @@
 V3XMATERIAL *V3XMaterials_GetFp(SYS_FILEHANDLE in, int numMaterial)
 {
     V3XMATERIAL *Mat;
+    u_int32_t *raw;
+    int i;
 	SYS_ASSERT(numMaterial < 255);
-	Mat = (V3XMATERIAL*)v3x_read_alloc(sizeof(V3XMATERIAL), numMaterial, -1, in);
-
+	
+    /* Unfortunately we cannot directly read the material struct from disk as
+       it contains (not used on disk) pointers, which on disk are 32 bit, but
+       may in reality be different (64 bits) see v3x_VMX_unpack_morph3D() for
+       a simpler example of the same problem. */
+    raw = (u_int32_t *)v3x_read_alloc(sizeof(u_int32_t), numMaterial * 32, -1, in);
+    Mat = (V3XMATERIAL*)MM_heap.malloc(numMaterial * sizeof(V3XMATERIAL));
+
+    /* copy the raw data to the material structs */
+    for (i=0;i<numMaterial;i++)
+    {
+      /* copy everything up to the textures */
+      memcpy(&Mat[i], raw, 14 * sizeof(u_int32_t));
+      /* each texture first has 2 ints, then 2 pointers */
+      memcpy(&Mat[i].texture[0], raw + 14, 2 * sizeof(u_int32_t));
+      Mat[i].texture[0].data = (u_int8_t *)(uintptr_t)raw[16];
+      Mat[i].texture[0].handle = (void *)(uintptr_t)raw[17];
+      memcpy(&Mat[i].texture[1], raw + 18, 2 * sizeof(u_int32_t));
+      Mat[i].texture[1].data = (u_int8_t *)(uintptr_t)raw[20];
+      Mat[i].texture[1].handle = (void *)(uintptr_t)raw[21];
+      Mat[i].reserved[0] = (void *)(uintptr_t)raw[22];
+      Mat[i].reserved[1] = (void *)(uintptr_t)raw[23];
+      Mat[i].fli = (struct _fli_struct *)(uintptr_t)raw[24];
+      Mat[i].render_clip = (void *)(uintptr_t)raw[25];
+      Mat[i].lod_near = raw[26];
+      Mat[i].lod_far  = raw[27];
+      /* copy the rest of the non ptr data starting at ambient */
+      memcpy(&Mat[i].ambient, raw + 28, 4 * sizeof(u_int32_t));
+      raw += 32;
+    }
+    raw -= numMaterial * 32;
+    MM_heap.free(raw);
+    
 #ifdef __BIG_ENDIAN__
 	{
     V3XMATERIAL *pMat = Mat;
-    int i;
     for (i=0;i<numMaterial;i++, pMat++)
     {
         u_int32_t info = pMat->lod;
@@ -1094,6 +1126,22 @@
 {
     for (;n!=0L;mono++, rgb++, n--) *mono = (V3XSCALAR)RGB_ToGray(rgb->r, rgb->g, rgb->b);
 }
+
+static void v3x_raw_to_mesh(u_int32_t *raw, V3XMESH *obj)
+{
+    /* copy the raw data to the in memory mesh struct */
+    /* even though the first 6 items are pointers they contain relevant info */
+    obj->vertex       = (V3XVECTOR *)  (uintptr_t)raw[0];
+    obj->face         = (V3XPOLY *)    (uintptr_t)raw[1];
+    obj->uv           = (V3XUV *)      (uintptr_t)raw[2];
+    obj->normal       = (V3XVECTOR *)  (uintptr_t)raw[3];
+    obj->normal_face  = (V3XVECTOR *)  (uintptr_t)raw[4];
+    obj->material     = (V3XMATERIAL *)(uintptr_t)raw[5];
+    memcpy(&obj->matrix, raw + 6, 27 * sizeof(u_int32_t));
+    obj->rgb = (rgb32_t *)(uintptr_t)raw[33];
+    memcpy(&obj->radius, raw + 34, 2 * sizeof(u_int32_t));
+}
+
 /*------------------------------------------------------------------------
 *
 * PROTOTYPE  :  V3XMESH static RLXAPI *v3x_VMX_unpack_object(SYS_FILEHANDLE in)
@@ -1104,7 +1152,15 @@
 V3XNODE static RLXAPI *v3x_VMX_unpack_node(SYS_FILEHANDLE in)
 {
     V3XMESH *obj;
-    obj =(V3XMESH*)v3x_read_alloc(sizeof(V3XMESH), 1, -1, in);
+    /* Unfortunately we cannot directly read the MESH struct from disk as
+       it contains (not used on disk) pointers, which on disk are 32 bit, but
+       may in reality be different (64 bits) see v3x_VMX_unpack_morph3D() for
+       a simpler example of the same problem. */
+    u_int32_t *raw = (u_int32_t *)v3x_read_alloc(sizeof(u_int32_t), 36, -1, in);
+    obj =(V3XMESH*)MM_heap.malloc(sizeof(V3XMESH));
+    v3x_raw_to_mesh(raw, obj);
+    MM_heap.free(raw);
+    
 #ifdef __BIG_ENDIAN__
     BSWAP32((u_int32_t*)&obj->matrix, 12);
 	BSWAP32((u_int32_t*)&obj->Tk, 3+3+1);
@@ -1118,7 +1174,16 @@
     V3XMESH *obj;
     int i;
     V3XPOLY *f;
-    obj =(V3XMESH*)v3x_read_alloc(sizeof(V3XMESH), 1, -1, in);
+
+    /* Unfortunately we cannot directly read the MESH struct from disk as
+       it contains (not used on disk) pointers, which on disk are 32 bit, but
+       may in reality be different (64 bits) see v3x_VMX_unpack_morph3D() for
+       a simpler example of the same problem. */
+    u_int32_t *raw = (u_int32_t *)v3x_read_alloc(sizeof(u_int32_t), 36, -1, in);
+    obj =(V3XMESH*)MM_heap.malloc(sizeof(V3XMESH));
+    v3x_raw_to_mesh(raw, obj);
+    MM_heap.free(raw);
+    
 #ifdef __BIG_ENDIAN__
     BSWAP16((u_int16_t*)&obj->numVerts, 4);
     BSWAP32((u_int32_t *)&obj->flags, 1);
@@ -1132,7 +1197,28 @@
 #ifdef __BIG_ENDIAN__        
         BSWAP32((u_int32_t*)obj->vertex , obj->numVerts*3);
 #endif
-        obj->face = (V3XPOLY*) v3x_read_alloc(sizeof(V3XPOLY) , obj->numFaces, -1, in);
+        /* Unfortunately we cannot directly read the POLY struct from disk as
+           it contains (not used on disk) pointers, which on disk are 32 bit, but
+           may in reality be different (64 bits) see v3x_VMX_unpack_morph3D() for
+           a simpler example of the same problem. */
+        raw = (u_int32_t *)v3x_read_alloc(sizeof(u_int32_t), 8 * obj->numFaces, -1, in);
+        obj->face =(V3XPOLY*)MM_heap.malloc(sizeof(V3XPOLY) * obj->numFaces);
+        /* copy the raw data to the in memory poly struct */
+        for (i = 0; i < obj->numFaces; i++)
+        {
+            u_int32_t *raw_poly = raw + i * 8;
+            V3XPOLY *poly = &obj->face[i];
+            poly->matIndex = raw_poly[0];
+            poly->faceTab  = (u_int32_t *)(uintptr_t)raw_poly[1];
+            poly->dispTab  = (V3XPTS *)(uintptr_t)raw_poly[2];
+            poly->uvTab    = (V3XUV **)(uintptr_t)raw_poly[3];
+            memcpy(&poly->distance, raw_poly + 4, sizeof(u_int32_t));
+            poly->rgb      = (rgb32_t*)(uintptr_t)raw_poly[5];
+            poly->ZTab     = (V3XWPTS*)(uintptr_t)raw_poly[6];
+            memcpy(&poly->numEdges, raw_poly + 7, sizeof(u_int32_t));
+        }
+        MM_heap.free(raw);
+
         if (obj->uv)
         {
             obj->uv =(V3XUV*) v3x_read_alloc(sizeof(V3XUV), obj->numVerts, -1, in);
@@ -1223,6 +1309,7 @@
     }
     return obj;
 }
+
 /*------------------------------------------------------------------------
 *
 * PROTOTYPE  :  V3XLIGHT static RLXAPI *v3x_VMX_unpack_light(SYS_FILEHANDLE in)
@@ -1233,7 +1320,22 @@
 V3XLIGHT static RLXAPI *v3x_VMX_unpack_light(SYS_FILEHANDLE in)
 {
     V3XLIGHT *light;
-    light = (V3XLIGHT*)v3x_read_alloc(sizeof(V3XNODE), 1, -1, in);
+    /* Unfortunately we cannot directly read the LIGHT struct from disk as
+       it contains (not used on disk) pointers, which on disk are 32 bit, but
+       may in reality be different (64 bits) see v3x_VMX_unpack_morph3D() for
+       a simpler example of the same problem. */
+    u_int32_t *raw = (u_int32_t *)v3x_read_alloc(sizeof(u_int32_t), 36, -1, in);
+    light =(V3XLIGHT*)MM_heap.malloc(sizeof(V3XLIGHT));
+
+    /* copy the raw data to the in memory mesh struct */
+    memcpy(light, raw, 17 * sizeof(u_int32_t));
+    light->material = (V3XMATERIAL *)(uintptr_t)raw[17];
+    memcpy(&light->flaresize, raw + 18, 2 * sizeof(u_int32_t));
+    light->reserved[0] = (void *)(uintptr_t)raw[20];
+    light->reserved[1] = (void *)(uintptr_t)raw[21];
+    memcpy(&light->Tk, raw + 22, 14 * sizeof(u_int32_t));
+    MM_heap.free(raw);
+
 #ifdef __BIG_ENDIAN__
     BSWAP32((u_int32_t*)&light->pos, 16);
 #endif
@@ -1259,7 +1361,15 @@
 V3XCAMERA static RLXAPI *v3x_VMX_unpack_camera(SYS_FILEHANDLE in)
 {
     V3XCAMERA *camera;
-    camera = (V3XCAMERA*)v3x_read_alloc(sizeof(V3XNODE), 1, -1, in);
+    /* Unfortunately we cannot directly read the CAMERA struct from disk as
+       we've added aditional padding to compensate for 64 bits pointers in
+       other structs with which we are in a union. */
+    u_int32_t *raw = (u_int32_t *)v3x_read_alloc(sizeof(u_int32_t), 36, -1, in);
+    camera =(V3XCAMERA*)MM_heap.malloc(sizeof(V3XCAMERA));
+    memcpy(camera, raw, 6 * sizeof(u_int32_t));
+    memcpy(&camera->M, raw + 6, 30 * sizeof(u_int32_t));
+    MM_heap.free(raw);
+
 #ifdef __BIG_ENDIAN__
     BSWAP32((u_int32_t*)&camera->M, 16);
 #endif
@@ -1274,20 +1384,70 @@
 */
 V3XCL static RLXAPI *v3x_VMX_unpack_collide(SYS_FILEHANDLE in)
 {
-    V3XCL *Cs = (V3XCL*) v3x_read_alloc(sizeof(V3XCL), 1, -1, in);
+    V3XCL *Cs =(V3XCL*)MM_heap.malloc(sizeof(V3XCL));
+    int i;
+
+    /* Unfortunately we cannot directly read the collision struct from disk as
+       it contains (not used on disk) pointers, which on disk are 32 bit, but
+       may in reality be different (64 bits) see v3x_VMX_unpack_morph3D() for
+       a simpler example of the same problem. */
+    u_int32_t *raw = (u_int32_t *)v3x_read_alloc(sizeof(u_int32_t), 22, -1, in);
+    
+    /* copy the raw data to the in memory struct */
+    memcpy(Cs, raw, 2 * sizeof(u_int32_t));
+    Cs->item = (V3XCL_ITEM *)(uintptr_t)raw[2];
+    memcpy(&Cs->global, raw + 3, 12 * sizeof(u_int32_t)); /* sphere */
+    Cs->mesh_ref = (V3XMESH *)(uintptr_t)raw[15];
+    memcpy(&Cs->flags, raw + 16, 2 * sizeof(u_int32_t));
+    memcpy(&Cs->old, raw + 18, sizeof(u_int32_t));
+    memcpy(&Cs->hitCount, raw + 19, 2 * sizeof(u_int32_t));
+    Cs->last_hit = (V3XCL_ITEM *)(uintptr_t)raw[21];
+    MM_heap.free(raw);
+
 #ifdef __BIG_ENDIAN__
     BSWAP32((u_int32_t*)Cs, 2);
 #endif
-	SYS_ASSERT(sizeof(V3XCL_ITEM) == 64);
-    Cs->item = (V3XCL_ITEM*)v3x_read_alloc(sizeof(V3XCL_ITEM), Cs->numItem, -1, in);
+    Cs->item = (V3XCL_ITEM*)MM_heap.malloc(sizeof(V3XCL_ITEM) * Cs->numItem);
+    /* Unfortunately we cannot directly read the collision item struct from
+       disk as it contains (not used on disk) pointers, which on disk are 32
+       bit, buts may in reality be different (64 bits) */
+    raw = (u_int32_t *)v3x_read_alloc(sizeof(u_int32_t), 16 * Cs->numItem, -1, in);
+    
+    for (i = 0; i < Cs->numItem; i++)
+    {
+        V3XCL_ITEM *item = &Cs->item[i];
+        u_int32_t *raw_item = raw + 16 * i;
+
+        item->type = raw_item[0];
+#ifdef __BIG_ENDIAN__
+        BSWAP32((u_int32_t*)&item->type, 1);
+#endif
+        if (item->type != V3XCTYPE_MESH)
+        {
+            /* disk and memory layout identical */
+            memcpy(((u_int32_t*)&item->type) + 1, raw_item + 1,
+                   15 * sizeof(u_int32_t));
+        }
+        else
+        {
+            /* copy the raw data to the in memory struct */
+            memcpy(&item->mesh.center, raw_item + 1, 7 * sizeof(u_int32_t));
+            item->mesh.face = (V3XCL_FACE *)(uintptr_t)raw_item[8];
+            item->mesh.sectorList = (u_int16_t *)(uintptr_t)raw_item[9];
+            item->mesh.maxsectors = raw_item[10];
+            item->mesh.mesh_ref = (V3XMESH *)(uintptr_t)raw_item[11];
+            /* skip 4 ints of unused padding (not there when using
+               64 bits pointers) */
+        }
+    }
+    
 #ifdef __BIG_ENDIAN__
     BSWAP32((u_int32_t*)&Cs->global, 9);
     {
         V3XCL_ITEM *item = Cs->item;
-        int i;
         for (i=Cs->numItem;i!=0;item++, i--)
         {
-            BSWAP32((u_int32_t*)&item->box.type , 16);
+            BSWAP32(((u_int32_t*)&item->box.type) + 1 , 15);
         }
     }
 #endif
@@ -1309,12 +1469,32 @@
 V3XTWEEN static RLXAPI *v3x_VMX_unpack_morph3D(SYS_FILEHANDLE in)
 {
     unsigned int i;
-    V3XTWEEN *Mo;
-    Mo = (V3XTWEEN*)v3x_read_alloc(sizeof(V3XTWEEN), 1, -1, in);
-#ifdef __BIG_ENDIAN__
-    BSWAP32((u_int32_t*)&Mo->numFrames, 3);
-#endif
-    if ((!Mo->numFrames)||(!Mo->numVerts)) return NULL;
+    /* The V3XTWEEN struct looks like this:
+    
+    typedef struct _v3x_morph{
+
+     V3XTWEENFRAME *frame; // Morphing frame
+     u_int32_t numFrames; // Number of frame
+     u_int32_t numVerts; // Number of vertex
+     u_int32_t numFaces; // Number of face
+    }V3XTWEEN;
+    
+    Unfortunately we cannot read this directly from disk as the on disk
+    format contains 32 bits (unused) frame pointers, and our pointers may
+    have a different size, so instead we read 4 32 bit ints and copy the
+    results to a V3XTWEEN structure */
+
+    V3XTWEEN *Mo = (V3XTWEEN *)MM_heap.malloc(sizeof(V3XTWEEN));
+    u_int32_t *raw = (u_int32_t *)v3x_read_alloc(sizeof(u_int32_t), 4, -1, in);
+#ifdef __BIG_ENDIAN__
+    BSWAP32(raw + 1, 3);
+#endif
+    Mo->frame     = (V3XTWEENFRAME *)(uintptr_t)raw[0];
+    Mo->numFrames = raw[1];
+    Mo->numVerts  = raw[2];
+    Mo->numFaces  = raw[3];
+    MM_heap.free(raw);
+    if ((!Mo->numFrames)||(!Mo->numVerts)) { MM_heap.free(Mo); return NULL; }
     Mo->frame = (V3XTWEENFRAME*) MM_heap.malloc(Mo->numFrames*sizeof(V3XTWEENFRAME));
     for (i=0;i<Mo->numFrames;i++)
     {
@@ -1383,8 +1563,17 @@
 * DESCRIPTION :
 *
 */
-static void RLXAPI v3x_VMX_unpack_TRI(V3XTRI *TRI, SYS_FILEHANDLE in)
+static void RLXAPI v3x_VMX_unpack_TRI(u_int32_t *rawTRI, V3XTRI *TRI,
+    SYS_FILEHANDLE in)
 {
+    /* Translate raw (on disk, pointers 32 bits, might be different in memory)
+       format to our in memory format */
+    TRI->keys = (V3XKEY *)(uintptr_t)rawTRI[0];
+    TRI->index_NEXT = rawTRI[1];
+    TRI->ORI_ref = (void *)(uintptr_t)rawTRI[2];
+    TRI->index_CHAIN = rawTRI[3];
+    memcpy(&TRI->pad, rawTRI + 4, 4 * sizeof(u_int32_t));
+        
 #ifdef __BIG_ENDIAN__
 	BSWAP32((u_int32_t *)&TRI->index_CHAIN, 1);
 	BSWAP16((u_int16_t*)&TRI->numFrames, 3);
@@ -1394,6 +1583,8 @@
     {
         if (TRI->flags&V3XKF_KEYEX)
         {
+            /* In this rare case  we can directly read the V3XKEYEX struct from disk as
+               it does not contain pointers! */
             TRI->keyEx=(V3XKEYEX*)v3x_read_alloc(sizeof(V3XKEYEX), TRI->numKeys, -1, in);
 #ifdef __BIG_ENDIAN__
             {
@@ -1409,6 +1600,8 @@
         }
         else
         {
+            /* In this rare case we can directly read the V3XKEY struct from
+               disk as it does not contain pointers! */
             TRI->keys=(V3XKEY*)v3x_read_alloc(sizeof(V3XKEY), TRI->numFrames, -1, in);
 #ifdef __BIG_ENDIAN__
             BSWAP32((u_int32_t*)TRI->keys, TRI->numFrames*7);
@@ -1427,34 +1620,47 @@
 
 static void v3xORI_Convert97(V3XSCENE *pScene, SYS_FILEHANDLE in)
 {
-    V3XORI97	*ori97A = (V3XORI97*)MM_std.malloc(pScene->numORI*sizeof(V3XORI97));
-    V3XORI97	*ori97;
+    V3XORI97	ori97;
     V3XORI		*ori;
+    u_int32_t *rawORIs = (u_int32_t *)MM_std.malloc(pScene->numORI * 16 *
+                                                    sizeof(u_int32_t));
     int i;
-    FIO_gzip.fread(ori97A, pScene->numORI, sizeof(V3XORI97), in);
+
+    /* Unfortunately we cannot directly read the struct from disk as
+       it contains (not used on disk) pointers, which on disk are 32 bit, but
+       may in reality be different (64 bits) */
+    FIO_gzip.fread(rawORIs, pScene->numORI, 16 * sizeof(u_int32_t), in);
     pScene->ORI = MM_CALLOC(pScene->numORI, V3XORI);
-    for (ori97 = ori97A, ori = pScene->ORI, i=0;i<pScene->numORI;i++, ori97++, ori++)
+    for (ori = pScene->ORI, i=0;i<pScene->numORI;i++, ori++)
     {
         const u_int8_t objTable[8] = { V3XOBJ_NONE, V3XOBJ_MESH, V3XOBJ_DUMMY, V3XOBJ_LIGHT, V3XOBJ_NONE, V3XOBJ_CAMERA, V3XOBJ_VIEWPORT};
+        u_int32_t *rawORI = rawORIs + 16 * i;
+        
+        /* copy the raw data to the in memory structs */
+        ori97.mesh  = (V3XMESH *) (uintptr_t)rawORI[0];
+        ori97.morph = (V3XTWEEN *)(uintptr_t)rawORI[1];
+        ori97.Cs    = (V3XCL *)   (uintptr_t)rawORI[2];
+        ori97.data  = (void *)    (uintptr_t)rawORI[3];
+        memcpy(&ori97.global_rayon, rawORI + 4, 12 * sizeof(u_int32_t));
 
 #ifdef __BIG_ENDIAN__
-        BSWAP32((u_int32_t* )&ori97->global_rayon, 1);
-        BSWAP32((u_int32_t* )&ori97->global_pivot, 3);
-        BSWAP16((u_int16_t*)&ori97->index_Parent, 1);
+        BSWAP32((u_int32_t* )&ori97.global_rayon, 1);
+        BSWAP32((u_int32_t* )&ori97.global_pivot, 3);
+        BSWAP16((u_int16_t*)&ori97.index_Parent, 1);
 #endif
         ori->flags = 0;
-        sysStrnCpy(ori->name, ori97->name, 16);
-        ori->type = objTable[ori97->Type];
-        ori->mesh = ori97->mesh;
-        ori->morph = ori97->morph;
-        ori->Cs = ori97->Cs;
-        ori->global_center = ori97->global_pivot;
-        ori->global_rayon = ori97->global_rayon;
-        ori->dataSize = ori97->index_Parent;
-        ori->pad2[0]  = ori97->matrix_Method;
-        ori->index_color = ori97->index_Color;
+        sysStrnCpy(ori->name, ori97.name, 16);
+        ori->type = objTable[ori97.Type];
+        ori->mesh = ori97.mesh;
+        ori->morph = ori97.morph;
+        ori->Cs = ori97.Cs;
+        ori->global_center = ori97.global_pivot;
+        ori->global_rayon = ori97.global_rayon;
+        ori->dataSize = ori97.index_Parent;
+        ori->pad2[0]  = ori97.matrix_Method;
+        ori->index_color = ori97.index_Color;
     }
-    MM_std.free(ori97A);
+    MM_std.free(rawORIs);
     return;
 }
 /*------------------------------------------------------------------------
@@ -1466,29 +1672,47 @@
 */
 static void v3xOVI_Convert97(V3XSCENE *pScene, SYS_FILEHANDLE in)
 {
-    V3XOVI97 *ovi97A = (V3XOVI97*)MM_std.malloc(pScene->numOVI*sizeof(V3XOVI97));
-    V3XOVI97  *ovi97;
+    V3XOVI97 ovi97;
     V3XOVI *ovi;
+    u_int32_t *rawOVIs = (u_int32_t *)MM_std.malloc(pScene->numOVI * 16 *
+                                                    sizeof(u_int32_t));
     int i;
-    FIO_gzip.fread(ovi97A, pScene->numOVI, sizeof(V3XOVI97), in);
+
+    /* Unfortunately we cannot directly read the struct from disk as
+       it contains (not used on disk) pointers, which on disk are 32 bit, but
+       may in reality be different (64 bits) */
+    FIO_gzip.fread(rawOVIs, pScene->numOVI, 16 * sizeof(u_int32_t), in);
     pScene->OVI = MM_CALLOC(pScene->numOVI, V3XOVI);
     
-	for (ovi97 = ovi97A, ovi = pScene->OVI, i = 0; i < pScene->numOVI; i++, ovi97++, ovi++)
+    for (ovi = pScene->OVI, i = 0; i < pScene->numOVI; i++, ovi++)
     {
+        u_int32_t *rawOVI = rawOVIs + 16 * i;
+        
+        /* copy the raw data to the in memory structs */
+        ovi97.mesh  = (V3XMESH *) (uintptr_t)rawOVI[0];
+        ovi97.data  = (void *)    (uintptr_t)rawOVI[1];
+        ovi97.Tk    = (V3XKEY *)  (uintptr_t)rawOVI[2];
+        ovi97.ORI   = (V3XORI *)  (uintptr_t)rawOVI[3];
+        ovi97.TVI   = (V3XTVI *)  (uintptr_t)rawOVI[4];
+        ovi97.Parent= (struct _ovi97 *) (uintptr_t)rawOVI[5];
+        ovi97.Child = (struct _ovi97 **)(uintptr_t)rawOVI[6];
+        ovi97.collisionList  = (struct _ovi97 *)(uintptr_t)rawOVI[7];
+        memcpy(&ovi97.distance, rawOVI + 8, 8 * sizeof(u_int32_t));
+        
 #ifdef __BIG_ENDIAN__
-        BSWAP16((u_int16_t*)&ovi97->index_OVI, 3);
+        BSWAP16((u_int16_t*)&ovi97.index_OVI, 3);
 #endif
         ovi->state = V3XSTATE_MATRIXUPDATE;
-        if (ovi97->Hide_Never)     
+        if (ovi97.Hide_Never)     
 			ovi->state|=V3XSTATE_CULLNEVER;
 			
-        if (ovi97->Hide_ByDisplay) 
+        if (ovi97.Hide_ByDisplay) 
 			ovi->state|=V3XSTATE_HIDDEN;
         
-		ovi->mesh = ovi97->mesh;
-        ovi->index_ORI = ovi97->index_ORI;
-        ovi->index_INSTANCE = ovi97->index_OVI;
-        ovi->index_TVI = ovi97->index_TVI;
+		ovi->mesh = ovi97.mesh;
+        ovi->index_ORI = ovi97.index_ORI;
+        ovi->index_INSTANCE = ovi97.index_OVI;
+        ovi->index_TVI = ovi97.index_TVI;
         ovi->matrix_Method = pScene->ORI[ovi->index_ORI].pad2[0];
         ovi->index_PARENT = pScene->ORI[ovi->index_ORI].dataSize;
     }
@@ -1500,13 +1724,15 @@
             ovi->index_PARENT = V3XScene_OVI_GetByName(pScene, pScene->ORI[j].name) - pScene->OVI;
         }
     }
-    MM_std.free(ovi97A);
+    MM_std.free(rawOVIs);
     return;
 }
 
 static void ReadSceneNodes(V3XSCENE *pScene, SYS_FILEHANDLE in, int bFormat97)
 {
     unsigned i;
+    u_int32_t *rawTRIs;
+    u_int32_t *rawTVIs;
     V3XLAYER *layer = &pScene->Layer;
     layer->tm.numFrames = 0;
     layer->tm.firstFrame = 0;
@@ -1514,6 +1740,7 @@
     if (bFormat97)
 		v3xORI_Convert97(pScene, in);
     else
+                /* Note: not fixed for 64 bits, currently bFormat97 always is true */
 		pScene->ORI = (V3XORI*)v3x_read_alloc(sizeof(V3XORI), pScene->numORI, V3X.Setup.MaxExtentableObjet, in);
     for (i=0;i<V3X.Setup.MaxExtentableObjet;i++)
     {
@@ -1523,9 +1750,25 @@
     if (bFormat97)
 		v3xOVI_Convert97(pScene, in);
     else
+                /* Note: not fixed for 64 bits, currently bFormat97 always is true */
 		pScene->OVI = (V3XOVI*) v3x_read_alloc(sizeof(V3XOVI), pScene->numOVI, V3X.Setup.MaxExtentableObjet, in);
-    pScene->TRI = (V3XTRI*) v3x_read_alloc(sizeof(V3XTRI), pScene->numTRI, V3X.Setup.MaxExtentableObjet, in);
-    pScene->TVI = (V3XTVI*) v3x_read_alloc(sizeof(V3XTVI), pScene->numTVI, V3X.Setup.MaxExtentableObjet, in);
+
+    /* Unfortunately we cannot directly read the structs from disk as
+       tkey contain (not used on disk) pointers, which on disk are 32 bit, but
+       may in reality be different (64 bits) */
+    pScene->TRI = (V3XTRI*)MM_heap.malloc(V3X.Setup.MaxExtentableObjet * sizeof(V3XTRI));
+    rawTRIs = (u_int32_t *)v3x_read_alloc(sizeof(u_int32_t), pScene->numTRI * 8, -1, in);
+    pScene->TVI = (V3XTVI*)MM_heap.malloc(V3X.Setup.MaxExtentableObjet * sizeof(V3XTVI));
+    rawTVIs = (u_int32_t *)v3x_read_alloc(sizeof(u_int32_t), pScene->numTVI * 4, -1, in);
+    /* copy the raw data to the in memory structs */
+    for (i = 0; i < pScene->numTVI; i++)
+    {
+        u_int32_t *rawTVI = rawTVIs + 4 * i;
+        pScene->TVI[i].index_TRI = rawTVI[0];
+        memcpy(&(pScene->TVI[i].frame), rawTVI + 1, 3 * sizeof(u_int32_t));
+    }
+    MM_heap.free(rawTVIs);
+
     if (bFormat97)
     {
         V3XTVI *TVI = pScene->TVI;
@@ -1546,16 +1789,18 @@
  	for (i=0;i<pScene->numTRI;i++)
     {
         V3XTRI *TRI = pScene->TRI + i;
-        v3x_VMX_unpack_TRI(pScene->TRI+i, in);
+        u_int32_t *rawTRI = rawTRIs + 8 * i;
+        v3x_VMX_unpack_TRI(rawTRI, TRI, in);
         if ( layer->tm.firstFrame < TRI->startFrame )
 			layer->tm.firstFrame = TRI->startFrame;
         if ( layer->tm.numFrames < TRI->numFrames )
 			layer->tm.numFrames = TRI->numFrames;
     }
+    MM_heap.free(rawTRIs);
     return;
 }
 
-#define HEAD1 sizeof(V3XSCENE) - sizeof(V3XLAYER)
+#define HEAD1 28
 _RLXEXPORTFUNC V3XSCENE RLXAPI *V3XScene_GetFromFile_VMX(const char *filename)
 {
     u_int8_t *temp, *sy;
@@ -1564,6 +1809,7 @@
     V3XLAYER97 *bk;
     V3XLAYER *layer = &pScene->Layer;
     V3X.Setup.flags|=V3XOPTION_97;
+    
     temp = (u_int8_t*) MM_std.malloc(HEAD1 + sizeof(V3XLAYER97));
     FIO_gzip.fread(temp, HEAD1 + sizeof(V3XLAYER97), 1, in);
     sysMemCpy(pScene, temp, HEAD1);
@@ -1689,6 +1935,8 @@
     }
     return pScene;
 }
+
+#if 0 /* not used! */
 /*------------------------------------------------------------------------
 *
 * PROTOTYPE  :  V3XOVI RLXAPI *V3XOVI_GetFromFile(V3XSCENE *pScene, char *filename)
@@ -1736,6 +1984,7 @@
             int k;
             j++;
             FIO_gzip.fread(ORI, 1, sizeof(V3XORI), in);
+            FIXME make 64 bits clean!
             v3x_VMX_unpack_ORI(ORI, in, 0);
             *OVI->node =* ORI->node;
             k = (flags>>8);
@@ -1753,6 +2002,8 @@
     FIO_gzip.fclose(in);
     return master;
 }
+#endif
+
 /*------------------------------------------------------------------------
 *
 * PROTOTYPE  :  V3XTVI RLXAPI *V3XTVI_GetFromFile(V3XSCENE *pScene, char *filename)
@@ -1763,6 +2014,7 @@
 V3XTVI RLXAPI *V3XTVI_GetFromFile(V3XSCENE *pScene, const char *filename)
 {
     u_int32_t flags;
+    u_int32_t rawTRI[8];
     SYS_FILEHANDLE in = FIO_gzip.fopen(filename, "rb");
     V3XTVI *master=NULL;
     if (!in)    return NULL;
@@ -1782,8 +2034,11 @@
 #ifdef __BIG_ENDIAN__
         BSWAP32(&flags, 1);
 #endif
-        FIO_gzip.fread(TRI, 1, sizeof(V3XTRI), in);
-        v3x_VMX_unpack_TRI(TRI, in);
+        /* Unfortunately we cannot directly read the material struct from disk
+           as it contains (not used on disk) pointers, which on disk are 32
+           bits, but may in reality be different (64 bits) */
+        FIO_gzip.fread(rawTRI, 1, 8 * sizeof(u_int32_t), in);
+        v3x_VMX_unpack_TRI(rawTRI, TRI, in);
     }while((flags&4)==0);
     return master;
 }
@@ -1797,6 +2052,7 @@
 V3XTRI RLXAPI *V3XTRI_GetFromFile(V3XSCENE *pScene, char *filename)
 {
     u_int32_t flags;
+    u_int32_t rawTRI[8];
     SYS_FILEHANDLE in = FIO_gzip.fopen(filename, "rb");
     V3XTRI *master=NULL;
     if (!in)    return NULL;
@@ -1812,8 +2068,11 @@
 #ifdef __BIG_ENDIAN__
         BSWAP32(&flags, 1);
 #endif
-        FIO_gzip.fread(TRI, 1, sizeof(V3XTRI), in);
-        v3x_VMX_unpack_TRI(TRI, in);
+        /* Unfortunately we cannot directly read the material struct from disk
+           as it contains (not used on disk) pointers, which on disk are 32
+           bits, but may in reality be different (64 bits) */
+        FIO_gzip.fread(rawTRI, 1, 8 * sizeof(u_int32_t), in);
+        v3x_VMX_unpack_TRI(rawTRI, TRI, in);
     }while((flags&4)==0);
     return master;
 }
diff -ur nogravity-2.00/rlx32/src/v3xsoft.c nogravity-2.00.new/rlx32/src/v3xsoft.c
--- nogravity-2.00/rlx32/src/v3xsoft.c	2005-02-24 20:15:02.000000000 +0100
+++ nogravity-2.00.new/rlx32/src/v3xsoft.c	2007-11-19 22:40:58.000000000 +0100
@@ -117,12 +117,12 @@
 }
 /*------------------------------------------------------------------------
 *
-* PROTOTYPE  :  #define ALGO3(fce)  ((u_int32_t)(((V3XMATERIAL*)(fce).Mat)->texture[0].handle))
+* PROTOTYPE  :  #define ALGO3(fce)  ((uintptr_t)(((V3XMATERIAL*)(fce).Mat)->texture[0].handle))
 *
 * Description :  
 *
 */
-#define ALGO3(fce)  ((u_int32_t)(((V3XMATERIAL*)(fce).Mat)->texture[0].handle))
+#define ALGO3(fce)  ((uintptr_t)(((V3XMATERIAL*)(fce).Mat)->texture[0].handle))
 /*------------------------------------------------------------------------
 *
 * PROTOTYPE  :
@@ -134,7 +134,7 @@
 {
     V3XPOLY **p = (si+((sj-si)>>1)), **sk, **sl;
     V3XPOLY  *q;
-    u_int32_t p0 = ALGO3(**p);
+    uintptr_t p0 = ALGO3(**p);
     for ( sk = si, sl = sj ; sk<=sl ; )
     {
         for( ; ALGO3(**sk)<p0 ; sk++ ){}
diff -ur nogravity-2.00/src/Linux/preferences.c nogravity-2.00.new/src/Linux/preferences.c
--- nogravity-2.00/src/Linux/preferences.c	2005-02-26 00:23:12.000000000 +0100
+++ nogravity-2.00.new/src/Linux/preferences.c	2007-11-17 22:25:13.000000000 +0100
@@ -26,7 +26,7 @@
 //-------------------------------------------------------------------------
 #include <stdio.h>
 #include <sys/stat.h>
-
+#include <stdlib.h>
 #include "_rlx32.h"
 #include "_rlx.h"
 #include "_stub.h"
diff -ur nogravity-2.00/src/console.c nogravity-2.00.new/src/console.c
--- nogravity-2.00/src/console.c	2005-02-24 20:16:48.000000000 +0100
+++ nogravity-2.00.new/src/console.c	2007-11-19 22:41:38.000000000 +0100
@@ -496,7 +496,7 @@
 
 	CSP_Color(0);
 	CSP_Alpha(128);
-	GX.gi.drawShadedRect(m_x, m_y, m_w, m_cH, (void*)cl);
+	GX.gi.drawShadedRect(m_x, m_y, m_w, m_cH, (void*)(uintptr_t)cl);
 
 	CSP_Color(0xffffffff);
 


--- NEW FILE nogravity--Makefile.am ---
if USE_OPENGL
RENDERER = ../../rlx32/src/renderers/opengl/gl_gx.cpp \
           ../../rlx32/src/renderers/opengl/gl_v3x.cpp \
           ../../rlx32/src/renderers/opengl/linux/sdl_gl.cpp
else
RENDERER = ../../rlx32/src/renderers/v3x_ref/z16_256.c \
           ../../rlx32/src/renderers/v3x_ref/r16_256.c \
           ../../rlx32/src/renderers/v3x_ref/r08_256.c\
           ../../rlx32/src/renderers/v3x_ref/z08_256.c \
           ../../rlx32/src/renderers/v3x_ref/r16_128.c \
           ../../rlx32/src/renderers/v3x_ref/z32_256.c \
           ../../rlx32/src/renderers/v3x_ref/r08_128.c \
           ../../rlx32/src/renderers/v3x_ref/r32_256.c \
           ../../rlx32/src/renderers/v3x_ref/v3xref.c \
           ../../rlx32/src/renderers/gfx_ref/sp8bit.c \
           ../../rlx32/src/renderers/gfx_ref/sp16bit.c \
           ../../rlx32/src/renderers/gfx_ref/gr32bit.c \
           ../../rlx32/src/renderers/gfx_ref/gx_drv.c \
           ../../rlx32/src/renderers/gfx_ref/gr16bit.c \
           ../../rlx32/src/renderers/gfx_ref/gr8bit.c \
           ../../rlx32/src/renderers/gfx_ref/sp32bit.c \
           ../../rlx32/src/linux/gx_sdl.cpp
endif

nogravitydir = $(prefix)/bin
nogravity_PROGRAMS = nogravity
nogravity_DATA = ../../GNU.TXT ../../README.TXT
nogravity_SOURCES = ../../rlx32/src/systools.c \
                    ../../rlx32/src/gx_csp.c \
                    ../../rlx32/src/v3xscene.c \
                    ../../rlx32/src/iss_form.c \
                    ../../rlx32/src/iss_av.c \
                    ../../rlx32/src/v3xcoll.c \
                    ../../rlx32/src/gx_rgb.c \
                    ../../rlx32/src/syslist.c \
                    ../../rlx32/src/gui_os.c \
                    ../../rlx32/src/gx_init.c \
                    ../../rlx32/src/syszlib.c \
                    ../../rlx32/src/sysresmx.c \
                    ../../rlx32/src/v3xsoft.c \
                    ../../rlx32/src/iss_ogg.c \
                    ../../rlx32/src/iss_cdc.c \
                    ../../rlx32/src/v3x_1.c \
                    ../../rlx32/src/gx_tool.c \
                    ../../rlx32/src/v3xrend.c \
                    ../../rlx32/src/gx_flc.c \
                    ../../rlx32/src/v3x_3.c \
                    ../../rlx32/src/_stub.cpp \
                    ../../rlx32/src/v3xscen2.c \
                    ../../rlx32/src/sysini.c \
                    ../../rlx32/src/gx_form.c \
                    ../../rlx32/src/iss_db.c \
                    ../../rlx32/src/gx_alloc.c \
                    ../../rlx32/src/v3x_2.c \
                    ../../rlx32/src/v3xdata.c \
                    ../../rlx32/src/v3xmaps.c \
                    ../../rlx32/src/sysgi.c \
                    ../../rlx32/src/gx_png.c \
                    ../../rlx32/src/linux/systool2.c \
                    ../../rlx32/src/linux/systime.c \
                    ../../rlx32/src/linux/snd.c \
                    ../../rlx32/src/linux/sysdbg.c \
                    ../../rlx32/src/linux/_stublinux.cpp \
                    ../../rlx32/src/linux/sysnet.c \
                    ../../rlx32/src/linux/sysreg.c \
                    ../../rlx32/src/linux/sysjoy.c \
                    ../../rlx32/src/linux/syskeyb.c \
                    ../../rlx32/src/linux/sysmouse.c \
                    ../../src/lt_game.c \
                    ../../src/lt_weap.c \
                    ../../src/lt_info.c \
                    ../../src/lt_video.c \
                    ../../src/lt_game2.c \
                    ../../src/ccmx.c \
                    ../../src/lt_menu.c \
                    ../../src/lt_sound.c \
                    ../../src/lt_save.c \
                    ../../src/lt_reso.c \
                    ../../src/lt_fx.c \
                    ../../src/console.c \
                    ../../src/lt_input.c \
                    ../../src/lt_data.c \
                    ../../src/lt_start.c \
                    ../../src/lithium.c \
                    ../../src/lt_st2.c \
                    ../../src/Linux/preferences.c \
                    $(RENDERER)
AM_CPPFLAGS = -I ../../rlx32/include -I ../../rlx32/src -I ../../rlx32/src/linux -I ../../rlx32/src/renderers/opengl -I ../../rlx32/src/renderers/opengl/linux -D__LINUX__

nogravity--README.patch:

--- NEW FILE nogravity--README.patch ---
diff -up nogravity-2.00/README.TXT~ nogravity-2.00/README.TXT
--- nogravity-2.00/README.TXT~	2007-12-30 12:02:04.000000000 +0100
+++ nogravity-2.00/README.TXT	2007-12-30 12:02:04.000000000 +0100
@@ -1,5 +1,5 @@
 ===================================================================
-No Gravity (v1.99 Version) Source Code Release - February 13, 2005
+No Gravity (v2.00 Version) Source Code and Data Release
 ===================================================================
 
  ===========================================================
@@ -10,13 +10,9 @@ No Gravity (v1.99 Version) Source Code R
 
 "No Gravity" copyright 1996 - 2005 RealTech. All trademarks and copyrights reserved.
 
-This is the complete source code for No Gravity version 1.98, buildable as detailed in the next section.
+This is the complete source code for No Gravity version 2.00, buildable as detailed in the next section.
 
-The code is licensed under the terms of the GPL (gnu public license).  You should read the entire license (filename "GNU.TXT" in this archive), so you understand your rights and what you can and cannot do with the source code from this release.
-
-All of the No Gravity data files remain copyrighted and licensed by RealTech under the original terms. You can use our data for personal entertainment or educational purposes.
-
-Please do not contact us for possible commercial exploitation of No Gravity -- we will not be interested.
+The code and data are licensed under the terms of the GPL (gnu public license).  You should read the entire license (filename "GNU.TXT" in this archive), so you understand your rights and what you can and cannot do with the source code from this release.
 
 Please note that this is being released without any kind of support from RealTech.
 


--- NEW FILE nogravity--bootstrap ---
#!/bin/sh
aclocal && autoheader && automake --foreign --add-missing && autoconf

nogravity--bufer-overflows.patch:

--- NEW FILE nogravity--bufer-overflows.patch ---
--- nogravity-2.00/rlx32/include/systools.h	2005-02-26 00:15:38.000000000 +0100
+++ nogravity-2.00.new/rlx32/include/systools.h	2007-12-30 23:15:14.000000000 +0100
@@ -111,11 +111,12 @@
 #define sysMemSet memset
 #define sysMemCpy memcpy
 #define sysStrCpy strcpy
-#define sysStrnCpy strncpy
 #define sysStrLen strlen
 #define sysMemZero(a, b) sysMemSet(a, 0, b)
 #define sysRand(a)  (rand()%(a))
 
+void sysStrnCpy(char *dest, const char *src, size_t n);
+
 #ifndef min
 #define min(a,b) ((a)<(b) ? a : b) 
 #define max(a,b) ((a)>(b) ? a : b) 
--- nogravity-2.00/rlx32/src/linux/systime.c	2005-07-10 22:46:28.000000000 +0200
+++ nogravity-2.00.new/rlx32/src/linux/systime.c	2007-12-30 22:08:31.000000000 +0100
@@ -26,6 +26,7 @@
 //------------------------------------------------------------------------- 
 #include <stdio.h>
 #include <SDL/SDL.h>
+#include <sched.h>
 
 #include "_rlx32.h"
 #include "systools.h"
--- nogravity-2.00/rlx32/src/sysgi.c	2005-06-17 21:59:34.000000000 +0200
+++ nogravity-2.00.new/rlx32/src/sysgi.c	2007-12-30 23:05:29.000000000 +0100
@@ -341,6 +341,10 @@
     int ok = 0;
     char __temp[256];
     unsigned l = strlen(texte);
+    
+    if (maxCharacters >= sizeof(__temp))
+        maxCharacters = sizeof(__temp) - 1;
+
     sysStrnCpy(__temp, texte, maxCharacters);
     do
     {
--- nogravity-2.00/rlx32/src/sysresmx.c	2005-06-17 21:59:34.000000000 +0200
+++ nogravity-2.00.new/rlx32/src/sysresmx.c	2007-12-30 23:16:37.000000000 +0100
@@ -26,7 +26,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
-#if defined __GNU_ || __BEOS__
+#if defined __unix__ || defined __GNU__ || defined __BEOS__
 #include <unistd.h>
 #endif
 #if defined _MSC_VER 
@@ -65,7 +65,7 @@
 }
 void MakePathUUU(char *dest, const char *path, const char *lpFilename)
 {
-	sysStrnCpy(dest, path, _MAX_PATH);
+	sysStrnCpy(dest, path, _MAX_PATH - 2);
 	AppendTrail(dest);
 	strcat(dest, lpFilename);
 }
@@ -105,7 +105,7 @@
 		return NULL;
 
 	filewad_setcurrent( pWad );
-	sysStrnCpy(pWad->s_FileName, lpFilename, _MAX_PATH);
+	sysStrnCpy(pWad->s_FileName, lpFilename, _MAX_PATH - 1);
 	pWad->mode |= (u_int8_t) flags;
 	pWad->mode &= ~SYS_WAD_STATUS_ENABLED;
 
@@ -581,7 +581,7 @@
 		pWad = filewad_getcurrent();
 
 	if (pWad)
-		sysStrnCpy(curpath, pWad->s_Path, len);
+		sysStrnCpy(curpath, pWad->s_Path, len - 1);
 #if !defined __MACOS__ && !defined _WINCE && !defined SN_TARGET_PS2 && !defined _XBOX
 	else
 		getcwd(curpath, len);
--- nogravity-2.00/rlx32/src/systools.c	2007-12-30 23:26:54.000000000 +0100
+++ nogravity-2.00.new/rlx32/src/systools.c	2007-12-30 23:14:22.000000000 +0100
@@ -515,3 +515,10 @@
     }
     return NULL;
 }
+
+void sysStrnCpy(char *dest, const char *src, size_t n)
+{
+    strncpy(dest, src, n);
+    /* important, n must be one less then the actual buffersize ! */
+    dest[n] = 0;
+}
--- nogravity-2.00/rlx32/src/v3xmaps.c	2005-05-29 13:17:06.000000000 +0200
+++ nogravity-2.00.new/rlx32/src/v3xmaps.c	2007-12-30 22:45:21.000000000 +0100
@@ -81,7 +81,7 @@
     }
     if (bi)
     {
-        sysStrnCpy(bi->filename, filename, 56);
+        sysStrnCpy(bi->filename, filename, 55);
         bi->data = data;
         bi->flags   |= 1;
         bi->type = (u_int8_t)type;
--- nogravity-2.00/rlx32/src/v3xscen2.c	2007-12-30 23:26:54.000000000 +0100
+++ nogravity-2.00.new/rlx32/src/v3xscen2.c	2007-12-30 22:43:40.000000000 +0100
@@ -1649,7 +1649,7 @@
         BSWAP16((u_int16_t*)&ori97.index_Parent, 1);
 #endif
         ori->flags = 0;
-        sysStrnCpy(ori->name, ori97.name, 16);
+        sysStrnCpy(ori->name, ori97.name, 15);
         ori->type = objTable[ori97.Type];
         ori->mesh = ori97.mesh;
         ori->morph = ori97.morph;
@@ -2142,7 +2142,7 @@
         *ORI = *cORI;
         ORI->Cs = NULL;//cORI->Cs;  
         sprintf(tex, "%s~%x", cOVI->ORI->name, (unsigned)(OVI-pScene->OVI));
-        sysStrnCpy(ORI->name, tex, 16);
+        sysStrnCpy(ORI->name, tex, 15);
         ORI->flags|=V3XORI_DUPLICATED|V3XORI_CSDUPLICATED;
         OVI->index_INSTANCE = cORI - pScene->ORI;  
 		assert(OVI->ORI!=NULL);		
--- nogravity-2.00/src/lt_cmx.h	2005-02-24 20:16:40.000000000 +0100
+++ nogravity-2.00.new/src/lt_cmx.h	2007-12-30 23:06:51.000000000 +0100
@@ -25,8 +25,8 @@
 //-------------------------------------------------------------------------
 typedef struct _sg_script
 {	
-	char Basename[12];
-	char Realname[12];
+	char Basename[13];
+	char Realname[13];
 	int32_t Shield, ShieldMax, Scoring, Sight, Poids;
 	int32_t Wait, ShootOk, Appear, AfterDeath;
 	float fSpeed, fFrozen, fSpeedMax;
--- nogravity-2.00/src/lt_info.c	2007-12-30 23:26:54.000000000 +0100
+++ nogravity-2.00.new/src/lt_info.c	2007-12-30 23:10:22.000000000 +0100
@@ -48,7 +48,7 @@
 
 char static *SaveKey(u_int8_t *table)
 {
-	char tex[256];
+    static char tex[256];
     char *s=tex;
     int i;
     *s = 0;
@@ -63,8 +63,8 @@
 
 static int ReadKey(char *s, u_int8_t *table)
 {
-    int i, d;
-    for (i=0, d=0;i<LK_MAX;i++, s+=3)
+    int i, d, len = strlen(s);
+    for (i=0, d=0;i<LK_MAX && (i*3) < len;i++, s+=3)
     {
         char te[4];
         sysStrnCpy(te, s, 3);
--- nogravity-2.00/src/lt_input.c	2006-01-27 00:39:52.000000000 +0100
+++ nogravity-2.00.new/src/lt_input.c	2007-12-30 22:09:55.000000000 +0100
@@ -25,6 +25,7 @@
 //-------------------------------------------------------------------------
 #define NG_EXPORT
 #include <stdio.h>
+#include <stdlib.h>
 #include "_rlx32.h"
 #include "sysctrl.h"
 #include "systools.h"


--- NEW FILE nogravity--configure.in ---
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT(nogravity, 1.99, http://sourceforge.net/projects/nogravity)
AM_INIT_AUTOMAKE(nogravity, 1.99)

AC_CONFIG_SRCDIR(preferences.c)
AC_CONFIG_HEADER(autoconfig.h)
AC_CONFIG_FILES([Makefile])

# Define arguments.
AC_ARG_ENABLE(debug,[  --enable-debug          Enable debug mode],
  [if test "$enableval" = "yes"
   then
     AC_DEFINE([_DEBUG], 1, [Define to 1 if debug mode is enabled.])
   fi])
use_opengl="yes"
AC_ARG_ENABLE(opengl, [  --enable-opengl         Enable use of OpenGL (enabled by default)],
  [if test "$enableval" = "no"
   then
     use_opengl="no"
   fi])
AM_CONDITIONAL(USE_OPENGL, test "$use_opengl" = "yes")
AC_ARG_ENABLE(sound, [  --enable-sound=type     Specify sound library (sdl_mixer or openal)],
  [sound="$enableval"])

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_STRUCT_TM

# Checks for standard headers and functions.
AC_HEADER_STDC
AC_CHECK_HEADERS([stddef.h stdint.h stdlib.h string.h unistd.h])
AC_FUNC_MALLOC
AC_FUNC_MEMCMP
AC_FUNC_REALLOC
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([atexit getcwd memmove memset mkdir pow strchr strstr strtol])

# Checks for SDL.  Note that we don't use AM_PATH_SDL because it's not always
# supported.
AC_CHECK_PROG(HAVE_SDL_CONFIG, [sdl-config], yes)
if test "$HAVE_SDL_CONFIG" = "yes"
then
  CFLAGS="`sdl-config --cflags` $CFLAGS"
  LIBSS="`sdl-config --libs` $LIBS"
else
  AC_MSG_WARN([Can't find sdl-config, guessing required headers and libraries.])
fi
AC_CHECK_HEADERS([SDL/SDL.h], , AC_MSG_ERROR([Can't find SDL headers.]))
AC_CHECK_LIB([SDL], [SDL_Init], , AC_MSG_ERROR([Can't find SDL library.]))

# If we're using OpenGL, test for it.
if test "$use_opengl" = "yes"
then
  # Checks for OpenGL.
  AC_CHECK_HEADERS([GL/gl.h], , AC_MSG_ERROR([Can't find OpenGL headers.]))
  AC_CHECK_LIB([GL], [glBegin], , AC_MSG_ERROR([Can't find OpenGL library.]))

  # Check for OpenGL 1.4 support.
  AC_CACHE_CHECK([for OpenGL 1.4 support], ac_cv_opengl_1_4_support, AC_TRY_RUN([
#include <GL/gl.h>"
#include <GL/glext.h>"
int main (int argc, char *argv[])
{
#ifdef GL_VERSION_1_4
  return 0;
#else
  return 1;
#endif
}
], [AS_VAR_SET(ac_cv_opengl_1_4_support, yes)], [AS_VAR_SET(ac_cv_opengl_1_4_support, no)]))
  AS_IF([test "AS_VAR_GET(ac_cv_opengl_1_4_support)" = "yes"], , AC_MSG_WARN([Some features will be disabled.]))
fi

# Checks for OpenAL (optional).
if test "$sound" = "openal"
then
  AC_CHECK_HEADERS([AL/al.h AL/alc.h], , AC_MSG_ERROR([Can't find OpenAL headers for sound.]))
  AC_CHECK_LIB([openal], [alGenSources], , AC_MSG_ERROR([Can't find OpenAL library for sound.]))
fi

# Checks for SDL_mixer (optional).
if test "$sound" = "sdl_mixer"
then
  AC_CHECK_HEADERS([SDL/SDL_mixer.h], , AC_MSG_ERROR([Can't find SDL_mixer headers for sound.]))
  AC_CHECK_LIB([SDL_mixer], [Mix_OpenAudio], , AC_MSG_ERROR([Can't find SDL_mixer library for sound.]))
fi

# Checks for libpng.
AC_CHECK_PROG(HAVE_LIBPNG_CONFIG, [libpng-config], yes)
if test "$HAVE_LIBPNG_CONFIG" = "yes"
then
  CFLAGS="`libpng-config --cflags` $CFLAGS"
  LDFLAGS="`libpng-config --ldflags` $LDFLAGS"
else
  AC_MSG_WARN([Can't find libpng-config, guessing required headers and libraries.])
fi
AC_CHECK_HEADERS([png.h], , AC_MSG_ERROR([Can't find libpng header.]))
AC_CHECK_LIB([png], [png_read_info], , AC_MSG_ERROR([Can't find libpng library.]))

# Checks for Ogg.
AC_CHECK_LIB([ogg], [ogg_stream_init], , AC_MSG_ERROR([Can't find Ogg library.]))

# Checks for Vorbis.
AC_CHECK_HEADERS([vorbis/codec.h], , AC_MSG_ERROR([Can't find Vorbis header.]))
AC_CHECK_LIB([vorbis], [vorbis_synthesis_init], , AC_MSG_ERROR([Can't find Vorbis library.]))

# Output it all.
AC_OUTPUT

nogravity--cvs.patch:

--- NEW FILE nogravity--cvs.patch ---
--- nogravity-2.00/rlx32/src/linux/snd_sdlmixer.c	2005-04-21 22:22:18.000000000 +0200
+++ nogravity/rlx32/src/linux/snd_sdlmixer.c	2006-05-27 11:04:29.000000000 +0200
@@ -46,6 +46,7 @@
   size_t pos;
   ssize_t start;
   ssize_t end;
+  u_int8_t vol;
   int8_t buf[409600];
 };
 
@@ -224,6 +225,17 @@
   return g_pchannels[channel].sam;
 }
 
+static void CopySample16(int16_t *dst, const int16_t *src, int len)
+{
+  while (len > 0)
+  {
+    *dst = (((int32_t)*src) * g_stream.vol) >> 8;
+    src ++;
+    dst ++;
+    len --;
+  }
+}
+
 static void StreamFill(void *dummy, Uint8 *stream, int len)
 {
   int music_len;
@@ -232,13 +244,13 @@
   music_len = (music_len > len) ? len : music_len;
   if (g_stream.start + music_len <= 409600)
   {
-    memcpy(stream, &g_stream.buf[g_stream.start], music_len);
+    CopySample16((int16_t *)stream, (int16_t *)&g_stream.buf[g_stream.start], music_len / 2);
     g_stream.start += music_len;
   }
   else
   {
-    memcpy(stream, &g_stream.buf[g_stream.start], 409600 - g_stream.start);
-    memcpy(&stream[409600 - g_stream.start], g_stream.buf, g_stream.start + music_len - 409600);
+    CopySample16((int16_t *)stream, (int16_t *)&g_stream.buf[g_stream.start], (409600 - g_stream.start) / 2);
+    CopySample16((int16_t *)&stream[409600 - g_stream.start], (int16_t *)g_stream.buf, (g_stream.start + music_len - 409600) / 2);
     g_stream.start = g_stream.start + music_len - 409600;
   }
   g_stream.pos += music_len;
@@ -265,6 +277,7 @@
     g_stream.pos = 0;
     g_stream.start = 0;
     g_stream.end = 0;
+    g_stream.vol = 255;
   }
   else
   {
@@ -298,7 +311,7 @@
 
 static void StreamSetVolume(V3XA_STREAM handle, float volume)
 {
-  // TODO: Implement.
+  g_stream.vol = volume * 255;
 }
 
 static int StreamLoad(V3XA_STREAM handle, void *data, size_t size)
--- nogravity-2.00/rlx32/src/renderers/opengl/gl_v3x.h	2005-06-17 21:58:20.000000000 +0200
+++ nogravity/rlx32/src/renderers/opengl/gl_v3x.h	2006-04-15 14:11:43.000000000 +0200
@@ -59,9 +59,9 @@
 #endif
 
 #elif (defined __LINUX__)
+#define GL_GLEXT_PROTOTYPES
 #include <GL/gl.h>
 #include <GL/glext.h>
-
 #ifndef GL_ARB_texture_rectangle
 #define GL_TEXTURE_RECTANGLE_ARB 0x84F5
 #endif
--- nogravity-2.00/src/lt_info.c	2006-01-25 21:10:16.000000000 +0100
+++ nogravity/src/lt_info.c	2006-04-15 14:11:43.000000000 +0200
@@ -77,6 +77,8 @@
                 table[i]=j;
                 d++;
             }
+	    else
+		table[i]=0;
         }
     }
     return d>=LK_MAX-1;

nogravity--fixed_path_to_game_data.diff:

--- NEW FILE nogravity--fixed_path_to_game_data.diff ---
--- src/lithium.c	2006-10-01 12:06:32.000000000 +0400
+++ src/lithium.c	2006-10-01 12:37:36.000000000 +0400
@@ -495,7 +495,7 @@
 
 void STUB_ReadyToRun(void)
 {
-	char *resFile = "NOGRAVITY.RMX";
+	char *resFile = "/usr/share/nogravity/NOGRAVITY.RMX";
 	
 #ifdef _DEBUG
     SYS_Debug("Open file resource : %s\n", resFile);

nogravity--fullscreen_as_option.patch:

--- NEW FILE nogravity--fullscreen_as_option.patch ---
diff -ru nogravity.orig/src/lithium.c nogravity/src/lithium.c
--- src/lithium.c	2006-02-15 02:04:30.000000000 +0300
+++ src/lithium.c	2006-10-01 11:56:11.000000000 +0400
@@ -235,7 +235,10 @@
 #if defined __BEOS__ || defined _DEBUG
 	RLX.Video.Config|=RLXVIDEO_Windowed;
 #else
- 	RLX.Video.Config&=~RLXVIDEO_Windowed;
+	if (g_SGSettings.Fullscreen == 1)
+	 	RLX.Video.Config&=~RLXVIDEO_Windowed;
+	 else
+	 	RLX.Video.Config|=RLXVIDEO_Windowed;
 #endif
 
 #ifdef _DEBUG
diff -ru nogravity.orig/src/lt_info.c nogravity/src/lt_info.c
--- src/lt_info.c	2006-04-15 16:11:43.000000000 +0400
+++ src/lt_info.c	2006-10-01 11:45:19.000000000 +0400
@@ -157,6 +157,7 @@
         fprintf(in, "Zbuffer=%s\n", YesNo[g_SGSettings.ZBuffer]);
 		fprintf(in, "ResolutionX=%d\n", (int)g_SGSettings.ResolutionX);
 		fprintf(in, "ResolutionY=%d\n", (int)g_SGSettings.ResolutionY);
+	fprintf(in, "Fullscreen=%d\n", (int)g_SGSettings.Fullscreen);
         fprintf(in, "ColorDepth=%d\n", g_SGSettings.ColorDepth);
         fprintf(in, "FrameSkip=%d\n", g_SGSettings.FrameSkip);
 		fprintf(in, "Multisampling=%d\n", g_SGSettings.Multisampling);
@@ -229,6 +230,7 @@
 			g_SGSettings.ColorDepth = (u_int8_t)GetCF_long("ColorDepth", &iniFile);
 
             g_SGSettings.Dithering = (u_int8_t)GetCF_bool("Dithering", &iniFile);
+	    g_SGSettings.Fullscreen = (u_int8_t)GetCF_bool("Fullscreen", &iniFile);
             g_SGSettings.TexFiltering = (u_int8_t)GetCF_bool("TexFiltering", &iniFile);
 			g_SGSettings.TexPOT = (u_int8_t)GetCF_bool("TexPOT", &iniFile);
             g_SGSettings.VisualsFx = (u_int8_t)GetCF_long("VisualsFx", &iniFile);
@@ -323,6 +325,7 @@
         g_SGSettings.Sky = 1;
         g_SGSettings.Dithering = 1;
         g_SGSettings.LensFX = 1;
+	g_SGSettings.Fullscreen = 1;
 		g_SGSettings.ResolutionX = 640;
 		g_SGSettings.ResolutionY = 480;
 		g_SGSettings.ColorDepth = 32;
diff -ru nogravity.orig/src/_nginfo.h nogravity/src/_nginfo.h
--- src/_nginfo.h	2006-02-15 02:04:30.000000000 +0300
+++ src/_nginfo.h	2006-10-01 11:40:12.000000000 +0400
@@ -42,6 +42,7 @@
     int			ResolutionX, ResolutionY, ColorDepth;
     int			ComNumber, ComTime, ComFTime;
     u_int8_t	VolDIG, VolFX, VolMusic;
+    u_int8_t Fullscreen;
     u_int8_t 	VisualsFx;
 	u_int8_t 	Interlaced;
     u_int8_t 	ZBuffer;

nogravity--openal.patch:

--- NEW FILE nogravity--openal.patch ---
--- nogravity-2.00/rlx32/src/linux/snd_openal.c	2005-05-07 11:46:24.000000000 +0200
+++ nogravity-2.00.new/rlx32/src/linux/snd_openal.c	2007-12-30 20:39:36.000000000 +0100
@@ -184,7 +184,8 @@
   }
   if (lpDistanceF != NULL)
   {
-    for (channel = 0; channel < g_nchannels; channel ++)
+    // g_nchannels - 1, highest channel is reserver for music / streams
+    for (channel = 0; channel < (g_nchannels - 1); channel ++)
     {
       alSourcef(g_pchannels[channel].src, AL_REFERENCE_DISTANCE, (ALfloat)*lpDistanceF);
     }
@@ -194,7 +195,8 @@
   }
   if (lpRolloffF != NULL)
   {
-    for (channel = 0; channel < g_nchannels; channel ++)
+    // g_nchannels - 1, highest channel is reserver for music / streams
+    for (channel = 0; channel < (g_nchannels - 1); channel ++)
     {
       alSourcef(g_pchannels[channel].src, AL_ROLLOFF_FACTOR, (ALfloat)*lpRolloffF);
     }
@@ -233,7 +235,9 @@
 
 static void ChannelSetSamplingRate(int channel, int sampleRate)
 {
-   alSourcef(g_pchannels[channel].src, AL_PITCH, 44100.0 / sampleRate);
+   float bufferSampleRate = g_pchannels[channel].sam?
+      g_pchannels[channel].sam->samplingRate : 44100.0;
+   alSourcef(g_pchannels[channel].src, AL_PITCH, bufferSampleRate / sampleRate);
 }
 
 static void ChannelSetParms(int channel, V3XVECTOR *pos, V3XVECTOR *velocity, V3XRANGE *fRange)
@@ -277,6 +281,8 @@
 static void ChannelStop(int channel)
 {
   alSourceStop(g_pchannels[channel].src);
+  g_pchannels[channel].sam = NULL;
+  g_pchannels[channel].play = FALSE;
 }
 
 static int ChannelGetStatus(int channel)
@@ -293,7 +299,8 @@
 static int ChannelGetFree(V3XA_HANDLE *sam)
 {
   int channel;
-  for (channel = 0; channel < g_nchannels; channel ++)
+  // g_nchannels - 1, highest channel is reserver for music / streams
+  for (channel = 0; channel < (g_nchannels - 1); channel ++)
   {
     if ((!g_pchannels[channel].play) &&
         (!g_pchannels[channel].stream))
@@ -301,7 +308,7 @@
       break;
     }
   }
-  if (channel >= g_nchannels)
+  if (channel >= (g_nchannels - 1))
   {
     channel = -1;
   }
@@ -311,7 +318,8 @@
 static void ChannelFlushAll(int mode)
 {
   int channel;
-  for (channel = 0; channel < g_nchannels; channel ++)
+  // g_nchannels - 1, highest channel is reserver for music / streams
+  for (channel = 0; channel < (g_nchannels - 1); channel ++)
   {
     if (ChannelGetStatus(channel))
     {
@@ -323,7 +331,8 @@
 static void ChannelInvalidate(V3XA_HANDLE *sam)
 {
   int channel;
-  for (channel = 0; channel < g_nchannels; channel ++)
+  // g_nchannels - 1, highest channel is reserver for music / streams
+  for (channel = 0; channel < (g_nchannels - 1); channel ++)
   {
     if ((g_pchannels[channel].sam == sam) &&
 	(ChannelGetStatus(channel)))
@@ -347,7 +356,7 @@
     alSourceUnqueueBuffers(g_pchannels[g_pstreams[handle].chan].src, 1, &g_pstreams[handle].bufs[g_pstreams[handle].first]);
     alDeleteBuffers(1, &g_pstreams[handle].bufs[g_pstreams[handle].first]);
     g_pstreams[handle].first ++;
-    if (g_pstreams[handle].first > g_nbufsperstream)
+    if (g_pstreams[handle].first >= g_nbufsperstream)
     {
       g_pstreams[handle].first = 0;
     }
@@ -368,12 +377,11 @@
 	g_pstreams[stream].first = 0;
 	g_pstreams[stream].last = 0;
 	g_pchannels[g_pstreams[stream].chan].stream = TRUE;
-	ChannelSetSamplingRate(g_pstreams[stream].chan, g_pstreams[stream].rate);
 	ChannelSetVolume(g_pstreams[stream].chan, 1.0);
 	ChannelSetPanning(g_pstreams[stream].chan, 0.0);
 	ChannelSetParms(g_pstreams[stream].chan, (V3XVECTOR *)&vector, (V3XVECTOR *)&vector, (V3XRANGE *)&range);
 	alSourcei(g_pchannels[g_pstreams[stream].chan].src, AL_LOOPING, AL_FALSE);
- 
+	alSourcef(g_pchannels[g_pstreams[stream].chan].src, AL_PITCH, 1.0);
 }
 
 static V3XA_STREAM StreamInitialize(int sampleFormat, int sampleRate, size_t size)
@@ -389,19 +397,12 @@
   }
   if (stream < g_nstreams)
   {
-    channel = 31;
-    if (channel != -1)
-    {
+	   channel = g_nchannels - 1;
 	   g_pstreams[stream].chan = channel;
 	   g_pstreams[stream].fmt = (sampleFormat & V3XA_FMTSTEREO) ?  ((sampleFormat & V3XA_FMT16BIT) ? AL_FORMAT_STEREO16 : AL_FORMAT_MONO16) : ((sampleFormat & V3XA_FMT16BIT) ? AL_FORMAT_STEREO8 : AL_FORMAT_MONO8);
    	   g_pstreams[stream].rate = sampleRate;
 
    	   StreamReset(stream);
-	}
-    else
-    {
-      stream = -1;
-    }
   }
   else
   {
@@ -442,16 +443,16 @@
     g_pstreams[handle].pos += size;
     alDeleteBuffers(1, &g_pstreams[handle].bufs[g_pstreams[handle].first]);
     g_pstreams[handle].first ++;
-    if (g_pstreams[handle].first > g_nbufsperstream)
+    if (g_pstreams[handle].first >= g_nbufsperstream)
     {
       g_pstreams[handle].first = 0;
     }
     processed --;
    }
   if (((g_pstreams[handle].last >= g_pstreams[handle].first) &&
-       (g_pstreams[handle].last - g_pstreams[handle].first <= 20)) ||
+       (g_pstreams[handle].last - g_pstreams[handle].first <= 25)) ||
       ((g_pstreams[handle].last < g_pstreams[handle].first) &&
-       (g_pstreams[handle].last + g_nbufsperstream - g_pstreams[handle].first <= 20)))
+       (g_pstreams[handle].last + g_nbufsperstream - g_pstreams[handle].first <= 25)))
   {
     ret_code = 0;
   }
@@ -475,7 +477,7 @@
     alBufferData(g_pstreams[handle].bufs[g_pstreams[handle].last], g_pstreams[handle].fmt, data, size, g_pstreams[handle].rate);
     alSourceQueueBuffers(g_pchannels[g_pstreams[handle].chan].src, 1, &g_pstreams[handle].bufs[g_pstreams[handle].last]);
     g_pstreams[handle].last ++;
-    if (g_pstreams[handle].last > g_nbufsperstream)
+    if (g_pstreams[handle].last >= g_nbufsperstream)
     {
       g_pstreams[handle].last = 0;
     }
--- nogravity-2.00/src/lt_sound.c	2005-06-17 21:59:34.000000000 +0200
+++ nogravity-2.00.new/src/lt_sound.c	2007-12-30 14:55:28.000000000 +0100
@@ -414,6 +414,7 @@
     if (RLX.Audio.Config&RLXAUDIO_Use3D)
     {
         V3XA.Client->ChannelSetParms(playChannel, pos, speed, NULL);
+        V3XA.Client->ChannelSetVolume(playChannel, (float)g_SGSettings.VolFX / 100);
 		return 1;
     }
     else
@@ -444,7 +445,7 @@
         {
             V3XRANGE range = {1000.f, 100000.f};
             info.smpHandle->sampleFormat|=V3XA_FMT3D;
-            V3XA.Client->ChannelPlay(info.playChannel, 44100, 1, 0, info.smpHandle);
+            V3XA.Client->ChannelPlay(info.playChannel, 44100, (float)g_SGSettings.VolFX / 100, 0, info.smpHandle);
             V3XA.Client->ChannelSetParms(info.playChannel, pos, speed, &range);
         }
         else

nogravity--snd_sdlmixer_c-powerpc-fix.diff:

--- NEW FILE nogravity--snd_sdlmixer_c-powerpc-fix.diff ---
diff -ru nogravity.orig/rlx32/src/linux/snd_sdlmixer.c nogravity/rlx32/src/linux/snd_sdlmixer.c
--- rlx32/src/linux/snd_sdlmixer.c	2006-05-27 13:04:29.000000000 +0400
+++ rlx32/src/linux/snd_sdlmixer.c	2006-10-01 11:44:25.000000000 +0400
@@ -84,7 +84,11 @@
 {
   // TODO: Check for failures (generally, not just in this file).
   SDL_InitSubSystem(SDL_INIT_AUDIO);
+#ifdef __powerpc__
+  Mix_OpenAudio(44100, AUDIO_S16MSB, 2, 1024);
+#else
   Mix_OpenAudio(44100, AUDIO_S16, 2, 1024);
+#endif
   Mix_ChannelFinished(ChannelFinished);
   return 0;
 }


--- NEW FILE nogravity.desktop ---
[Desktop Entry]
Name=NoGravity
Comment=Space shooter in 3D
Exec=nogravity
Icon=nogravity
StartupNotify=false
Terminal=false
Type=Application
Categories=Game;ActionGame;


--- NEW FILE nogravity.sh ---
#!/bin/bash

if [ `glxinfo | grep "direct rendering: " | head -n 1 | cut -d " " -f 3` != Yes ]; then
  exec nogravity-software "$@"
else
  exec nogravity-opengl "$@"
fi


--- NEW FILE nogravity.spec ---
Name:           nogravity
Version:        2.00
Release:        5%{?dist}
Summary:        Space shooter in 3D
Group:          Amusements/Games
License:        GPLv2+
URL:            http://www.realtech-vr.com/nogravity/
Source0:        http://downloads.sourceforge.net/%{name}/rt-%{name}-src.zip
Source2:        %{name}.desktop
Source3:        %{name}.png
Source4:        nogravity--Makefile.am
Source5:        nogravity--bootstrap
Source6:        nogravity--configure.in
Source7:        nogravity.sh
Patch0:         nogravity--snd_sdlmixer_c-powerpc-fix.diff
Patch1:         nogravity--fullscreen_as_option.patch
Patch2:         nogravity--fixed_path_to_game_data.diff
Patch3:         nogravity--64-bit.patch
Patch4:         nogravity--cvs.patch
Patch5:         nogravity--openal.patch
# See: https://www.redhat.com/archives/fedora-games-list/2007-June/msg00000.html
Patch6:         nogravity--README.patch
Patch7:         nogravity--bufer-overflows.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires:       %{name}-data = %{version}
BuildRequires:  SDL_mixer-devel openal-devel libpng-devel libvorbis-devel
BuildRequires:  automake desktop-file-utils
Requires:       hicolor-icon-theme glx-utils

%description
No Gravity is a fantastic and futuristic universe made of five
intergalactic worlds. An arcade type game with great playability,
where it is easy to plunge into space battles against spacefighters,
space stations and more!


%prep
%setup -q -c
cp %{SOURCE4} ./src/Linux/Makefile.am
cp %{SOURCE5} ./src/Linux/bootstrap
cp %{SOURCE6} ./src/Linux/configure.in
%patch0 -b .snd_sdlmixer_c-powerpc-fix
%patch1 -b .fullscreen_as_option 
%patch2 -b .fixed_path_to_game_data
%patch3 -p1 -b .64-bit
%patch4 -p1 -b .cvs
%patch5 -p1 -b .openal
%patch6 -p1 -b .license
%patch7 -p1 -b .buf-oflow
sed -i 's/\r//g' GNU.TXT README.TXT
pushd src/Linux
sh bootstrap
popd


%build
pushd src/Linux

%configure --enable-sound=sdl_mixer --disable-opengl
make %{?_smp_mflags}
mv %{name} %{name}-software

make distclean

%configure --enable-sound=openal --enable-opengl
make %{?_smp_mflags}
mv %{name} %{name}-opengl

popd


%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_bindir}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/applications
mkdir -p $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/48x48/apps
install -m 755 src/Linux/%{name}-software $RPM_BUILD_ROOT%{_bindir}
install -m 755 src/Linux/%{name}-opengl   $RPM_BUILD_ROOT%{_bindir}
install -p -m 755 %{SOURCE7} $RPM_BUILD_ROOT%{_bindir}/%{name}
desktop-file-install --vendor fedora            \
  --dir $RPM_BUILD_ROOT%{_datadir}/applications \
  %{SOURCE2}
install -p -m 644 %{SOURCE3} \
$RPM_BUILD_ROOT%{_datadir}/icons/hicolor/48x48/apps/%{name}.png


%clean
rm -rf $RPM_BUILD_ROOT


%post
touch --no-create %{_datadir}/icons/hicolor || :
if [ -x %{_bindir}/gtk-update-icon-cache ]; then
   %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
fi

%postun
touch --no-create %{_datadir}/icons/hicolor || :
if [ -x %{_bindir}/gtk-update-icon-cache ]; then
   %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
fi


%files
%defattr(-,root,root,-)
%doc GNU.TXT README.TXT
%{_bindir}/%{name}*
%{_datadir}/applications/fedora-%{name}.desktop
%{_datadir}/icons/hicolor/48x48/apps/%{name}.png


%changelog
* Fri Jan 11 2008 Hans de Goede <j.w.r.degoede at hhs.nl> 2.00-5
- Fix wrapper script to work with duel head configurations

* Sun Dec 30 2007 Hans de Goede <j.w.r.degoede at hhs.nl> 2.00-4
- Activate my 64 bit patch
- Add icon cache scriplets
- Use sed rather then dos2unix
- Build both a software rendering version and an opengl version, add a wrapper
  script which chooses which one to use based on the availabiliy of DRI
- Patch README to reflect that the data is GPL licensed too now
- Move datafile from /usr/games/nogravity to /usr/share/nogravity
- Make nogravity startup fullscreen by default
- Fix openal sound effects volume control and some other minor openal issues
- Fix several wrong memory uses and non 0 terminated strings, strncpy is evil!
  This fixes saving modified keybindings and hopefully also the odd segfault

* Sat Dec 29 2007 Rahul Sundaram <sundaram at fedoraproject.org> 2.00-3
- Split engine and data. List patch from Hans

* Mon Nov 26 2007 Peter Lemenkov <lemenkov at gmail.com> 2.00-2
- Various fixes according to https://bugzilla.redhat.com/show_bug.cgi?id=366841#c2

* Thu Oct  4 2007 Peter Lemenkov <lemenkov at gmail.com> 2.00-1
- Fixed download paths
- Fixed license as required

* Sun Oct  1 2006 Peter Lemenkov <lemenkov at gmail.com> 2.00-0.lvn.2
- Clean up BuildRequires
- Added patch for enabling/disabling fullscreen-mode (via config-file)
- Added patch for proper path to resource-file
- Dropped startup script (no longer necessary)
- Fixed audio at PowerPC-arch
- Disabled OpenGL (seems to be broken)


Index: .cvsignore
===================================================================
RCS file: /cvs/extras/rpms/nogravity/devel/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore	28 Jan 2008 15:37:40 -0000	1.1
+++ .cvsignore	30 Jan 2008 10:05:18 -0000	1.2
@@ -0,0 +1 @@
+rt-nogravity-src.zip


Index: sources
===================================================================
RCS file: /cvs/extras/rpms/nogravity/devel/sources,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sources	28 Jan 2008 15:37:40 -0000	1.1
+++ sources	30 Jan 2008 10:05:18 -0000	1.2
@@ -0,0 +1 @@
+b5ec0984d8688776edf4074d309df8b1  rt-nogravity-src.zip




More information about the fedora-extras-commits mailing list