Bug#503883: netmaze: problems with -texture option on 64-bit processors

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug#503883: netmaze: problems with -texture option on 64-bit processors

Steve Cotton-2
Package: netmaze
Version: 0.81+jpg0.82-12.1
Severity: normal

Three problems with using the -texture option:
1. It tries to find a bitmap relative to current directory
2. If it finds it, it will crash when you press 1 to start the game
   (on AMD64, other archs not tested)
3. Non-64-bit code in texture.c, likely cause of problem 2.

steve@localhost:~$ netmaze -texture
Defaultmaze is ok!
Can't load texture: ./lib//hwall.bmp
Can't load texturedata!.

steve@localhost:~$ cd /usr/lib/games/netmaze/
steve@localhost:/usr/lib/games/netmaze$ netmaze -texture
Defaultmaze is ok!
Used Texturememory: 270384
Ok, using faster shared memory PutImage.
Press '1' to start game!
*** New game with 8 player(s) starts! ***
    Player Nr. 0: Number: 0     Team: 0
    Player Nr. 1: Number: 1     Team: 1
    Player Nr. 2: Number: 2     Team: 2
    Player Nr. 3: Number: 3     Team: 3
    Player Nr. 4: Number: 4     Team: 0
    Player Nr. 5: Number: 5     Team: 1
    Player Nr. 6: Number: 6     Team: 2
    Player Nr. 7: Number: 7     Team: 3
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  148 (MIT-SHM)
  Minor opcode of failed request:  3 (X_ShmPutImage)
  Serial number of failed request:  805
  Current serial number in output stream:  806
(crash)


The compiler warns about pointer casts:
    texture.c: In function ‘load_texture’:
    texture.c:397: warning: cast from pointer to integer of different size
    texture.c:397: warning: cast to pointer from integer of different size
    texture.c:401: warning: cast from pointer to integer of different size
    texture.c:401: warning: cast to pointer from integer of different size
those lines force alignment of data, assuming 32-bit pointers:
    tex->data = (char *) (((int) malloc(w*h+4) + 3) & 0xfffffffc);

Grepping through the source for interesting numbers starting 0xfff, there's a
similar problem in audio:
./audio.c:  data = (char *) ((malloc(blen*play_delay+16)+15) & 0xfffffff0);


Also the bots don't move; maybe I'm missing a config option or maybe that's
another 64-bit problem.

Steve

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (990, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages netmaze depends on:
ii  libc6                         2.7-15     GNU C Library: Shared libraries
ii  libx11-6                      2:1.1.5-2  X11 client-side library
ii  libxext6                      2:1.0.4-1  X11 miscellaneous extension librar
ii  tix [tix]                     8.4.0-6    The Tix library for Tk -- runtime
ii  tk8.4                         8.4.19-2   Tk toolkit for Tcl and X11, v8.4 -

netmaze recommends no packages.

netmaze suggests no packages.

-- no debconf information



--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Bug#503883: netmaze: problems with -texture option on 64-bit processors

John Goerzen-3
Steve Cotton wrote:
> steve@localhost:~$ netmaze -texture
> Defaultmaze is ok!
> Can't load texture: ./lib//hwall.bmp
> Can't load texturedata!.

As far as I am aware, the -texture option has never worked for me.

Unfortuantely upstream for this game has long since abandoned it.  It
may prove useful to just limit it to 32-bit archs in debian/control, I
suppose.




--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Bug#503883: netmaze: problems with -texture option on 64-bit processors

Craig Prevallet
In reply to this post by Steve Cotton-2
On Wed, 29 Oct 2008 00:55:04 +0000 Steve Cotton
<[hidden email]> wrote:
 > Package: netmaze
 > Version: 0.81+jpg0.82-12.1
 > Severity: normal
 >
 > Three problems with using the -texture option:
 > 1. It tries to find a bitmap relative to current directory
 > 2. If it finds it, it will crash when you press 1 to start the game
 > (on AMD64, other archs not tested)
 > 3. Non-64-bit code in texture.c, likely cause of problem 2.
 >
 > steve@localhost:~$ netmaze -texture
 > Defaultmaze is ok!
 > Can't load texture: ./lib//hwall.bmp
 > Can't load texturedata!.
 >
 > steve@localhost:~$ cd /usr/lib/games/netmaze/
 > steve@localhost:/usr/lib/games/netmaze$ netmaze -texture
 > Defaultmaze is ok!
 > Used Texturememory: 270384
 > Ok, using faster shared memory PutImage.
 > Press '1' to start game!
 > *** New game with 8 player(s) starts! ***
 > Player Nr. 0: Number: 0 Team: 0
 > Player Nr. 1: Number: 1 Team: 1
 > Player Nr. 2: Number: 2 Team: 2
 > Player Nr. 3: Number: 3 Team: 3
 > Player Nr. 4: Number: 4 Team: 0
 > Player Nr. 5: Number: 5 Team: 1
 > Player Nr. 6: Number: 6 Team: 2
 > Player Nr. 7: Number: 7 Team: 3
 > X Error of failed request: BadMatch (invalid parameter attributes)
 > Major opcode of failed request: 148 (MIT-SHM)
 > Minor opcode of failed request: 3 (X_ShmPutImage)
 > Serial number of failed request: 805
 > Current serial number in output stream: 806
 > (crash)
 >
 >
 > The compiler warns about pointer casts:
 > texture.c: In function ‘load_texture’:
 > texture.c:397: warning: cast from pointer to integer of different size
 > texture.c:397: warning: cast to pointer from integer of different size
 > texture.c:401: warning: cast from pointer to integer of different size
 > texture.c:401: warning: cast to pointer from integer of different size
 > those lines force alignment of data, assuming 32-bit pointers:
 > tex->data = (char *) (((int) malloc(w*h+4) + 3) & 0xfffffffc);
 >
 > Grepping through the source for interesting numbers starting 0xfff,
there's a
 > similar problem in audio:
 > ./audio.c: data = (char *) ((malloc(blen*play_delay+16)+15) &
0xfffffff0);
 >
 >
 > Also the bots don't move; maybe I'm missing a config option or maybe
that's
 > another 64-bit problem.
 >
 > Steve
 >
 > -- System Information:
 > Debian Release: lenny/sid
 > APT prefers unstable

I realize this bug is 10 years old (for a 20+ year old program!) but I
have textures working again in Debian 9 (Stretch) amd64 bit.

I had to resolve 2 problems in order to make it work.

The first is resolved by replacing the 32 bit memory alignment code
noted by Steve with calls to posix_memalign and recompiling:

-------- texture.c ----------------------------------
index ffbc6ab..43ca711 100644
@@ -394,11 +394,17 @@ struct texture *load_texture(char *name)
    {
      tex->datatab = malloc( sizeof(char *) * (h+1) );
      texturemem += (h>>1)*w*h+((w*h)>>1)+4;
-    tex->data = (char *) (((int) malloc((h>>1)*w*h+((w*h)>>1)+4) + 3) &
0xfffffffc);
+    //tex->data = (char *) (((int) malloc((h>>1)*w*h+((w*h)>>1)+4) + 3)
& 0xfffffffc);
+    void *memptr = NULL;
+    tex->data = posix_memalign(&memptr, 32, (h>>1)*w*h+((w*h)>>1)+4);
+    tex->data = memptr;
    }
    else
    {
-    tex->data = (char *) (((int) malloc(w*h+4) + 3) & 0xfffffffc);
+    //tex->data = (char *) (((int) malloc(w*h+4) + 3) & 0xfffffffc);
+    void *memptr = NULL;
+    tex->data = posix_memalign(&memptr, 32, w*h+4 );
+    tex->data = memptr;
      texturemem += w*h+4;
    }

The second is that the code in question was experimental when it was
written and actually requires 8 bit graphics NOT 8 bit or better -- as
evidenced by the call to XShmCreateImage in x11gfx.c.  The fix is to run
the code at an 8 bit graphics depth.  Unfortunately my system's Nouveau
graphic driver didn't support that depth directly so I took a hint from
here
(https://unix.stackexchange.com/questions/287695/how-can-i-run-linux-in-256-color)
and ran it from within Xephyr.

xinit $(which xterm) -- $(which Xephyr) :1 -screen 1024x768x8 -br -reset
-terminate

followed by:  netmaze -texture

from within generated xterm.

This allows the texture mapped graphics to occur.  See attached for a
screenshot.  Hope this helps.

Regards,

Craig Prevallet


xephyr.png (259K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Bug#503883: netmaze: problems with -texture option on 64-bit processors

John Goerzen-3
Thanks, Craig!  That's a great find.  I remember even back on the SunOS
system where I first used it, the textures never worked.  I'll integrate
this into a future release.

-- John