Last night I tried to fix games/ivan for sparc64, but gave up.  For
the record, here's how far I got, in case somebody wants to go down
the same road.

(1) Unaligned access once the SDL window opens.  This is due to an
    optimization in the character drawing code that wants to process
    two 16-bit values in a 32-bit operation.
    Fix: Go back to processing 16-bit values singly.

(2) Unaligned access when generating a game.  The author wants a
    class to be memcmp()-able.  Since undefined values in the padding
    between members screws that up, they are __packed__.  That works
    for direct accesses, but not for passing unaligned members to
    functions that aren't prepared for this.
    Fix: Drop the packing, zero out with memset() in constructor. Ewww.

With that my character could amble around in the landscape.
I wasn't interested in the game itself, but random play actions
eventually go me

(3) Another unaligned access.

#0  0x00000007d61ff808 in bitmap::AlphaLuminanceBlit (this=Variable "this" is 
not available.
) at bitmap.cpp:1323
1323        const packcol16* SrcPtr = &SrcImage[B.Src.Y + y][B.Src.X];
(gdb) p SrcImage
$1 = (packcol16 **) 0xdfdfdfdfdfdfdfdf

Ugh.  So the memory handling is broken too.  And I don't even have
any malloc options enabled.

At this point I lost interest.


Index: patches/patch-FeLib_Source_bitmap_cpp
===================================================================
RCS file: /cvs/ports/games/ivan/patches/patch-FeLib_Source_bitmap_cpp,v
retrieving revision 1.2
diff -u -p -r1.2 patch-FeLib_Source_bitmap_cpp
--- patches/patch-FeLib_Source_bitmap_cpp       23 May 2010 15:58:02 -0000      
1.2
+++ patches/patch-FeLib_Source_bitmap_cpp       3 Aug 2015 11:42:42 -0000
@@ -1,6 +1,9 @@
 $OpenBSD: patch-FeLib_Source_bitmap_cpp,v 1.2 2010/05/23 15:58:02 espie Exp $
+
+Do not use larger accesses on 16-bit-aligned values.
+
 --- FeLib/Source/bitmap.cpp.orig       Tue Oct 26 21:35:47 2004
-+++ FeLib/Source/bitmap.cpp    Sat May 22 07:28:38 2010
++++ FeLib/Source/bitmap.cpp    Sun Aug  2 17:37:37 2015
 @@ -2047,10 +2047,10 @@ void cachedfont::PrintCharacter(const blitdata B) cons
  
    for(; SrcLine != EndLine; ++SrcLine, ++SrcMaskLine, ++DestLine)
@@ -9,10 +12,10 @@ $OpenBSD: patch-FeLib_Source_bitmap_cpp,
 -    const ulong* EndPtr = FontPtr + 5;
 -    const ulong* MaskPtr = reinterpret_cast<const ulong*>(*SrcMaskLine + 
B.Src.X);
 -    ulong* DestPtr = reinterpret_cast<ulong*>(*DestLine + B.Dest.X);
-+    const uint32_t* FontPtr = reinterpret_cast<const uint32_t*>(*SrcLine + 
B.Src.X);
-+    const uint32_t* EndPtr = FontPtr + 5;
-+    const uint32_t* MaskPtr = reinterpret_cast<const uint32_t*>(*SrcMaskLine 
+ B.Src.X);
-+    uint32_t* DestPtr = reinterpret_cast<uint32_t*>(*DestLine + B.Dest.X);
++    const packcol16* FontPtr = *SrcLine + B.Src.X;
++    const packcol16* EndPtr = FontPtr + 10;
++    const packcol16* MaskPtr = *SrcMaskLine + B.Src.X;
++    packcol16* DestPtr = *DestLine + B.Dest.X;
  
      for(; FontPtr != EndPtr; ++DestPtr, ++MaskPtr, ++FontPtr)
        *DestPtr = *DestPtr & *MaskPtr | *FontPtr;
Index: patches/patch-Main_Include_igraph_h
===================================================================
RCS file: patches/patch-Main_Include_igraph_h
diff -N patches/patch-Main_Include_igraph_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Main_Include_igraph_h 3 Aug 2015 11:42:42 -0000
@@ -0,0 +1,62 @@
+$OpenBSD$
+--- Main/Include/igraph.h.orig Tue Oct 26 21:36:42 2004
++++ Main/Include/igraph.h      Sun Aug  2 23:43:14 2015
+@@ -24,39 +24,29 @@ class outputfile;
+ class inputfile;
+ class festring;
+ 
+-/* memcmp doesn't like alignment of structure members */
+-
+-#ifdef VC
+-#pragma pack(1)
+-#endif
+-
+ struct graphicid
+ {
+-  graphicid() { }
++  graphicid() { memset(this, 0, sizeof(*this)); }
+   bool operator<(const graphicid&) const;
+-  ushort BitmapPosX NO_ALIGNMENT;
+-  ushort BitmapPosY NO_ALIGNMENT;
+-  packcol16 Color[4] NO_ALIGNMENT;
+-  uchar Frame NO_ALIGNMENT;
+-  uchar FileIndex NO_ALIGNMENT;
+-  ushort SpecialFlags NO_ALIGNMENT;
+-  packalpha Alpha[4] NO_ALIGNMENT;
+-  packalpha BaseAlpha NO_ALIGNMENT;
+-  uchar SparkleFrame NO_ALIGNMENT;
+-  uchar SparklePosX NO_ALIGNMENT;
+-  uchar SparklePosY NO_ALIGNMENT;
+-  packcol16 OutlineColor NO_ALIGNMENT;
+-  packalpha OutlineAlpha NO_ALIGNMENT;
+-  uchar FlyAmount NO_ALIGNMENT;
+-  v2 Position NO_ALIGNMENT;
+-  uchar RustData[4] NO_ALIGNMENT;
+-  ushort Seed NO_ALIGNMENT;
+-  uchar WobbleData NO_ALIGNMENT;
++  ushort BitmapPosX;
++  ushort BitmapPosY;
++  packcol16 Color[4];
++  uchar Frame;
++  uchar FileIndex;
++  ushort SpecialFlags;
++  packalpha Alpha[4];
++  packalpha BaseAlpha;
++  uchar SparkleFrame;
++  uchar SparklePosX;
++  uchar SparklePosY;
++  packcol16 OutlineColor;
++  packalpha OutlineAlpha;
++  uchar FlyAmount;
++  v2 Position;
++  uchar RustData[4];
++  ushort Seed;
++  uchar WobbleData;
+ };
+-
+-#ifdef VC
+-#pragma pack()
+-#endif
+ 
+ inline bool graphicid::operator<(const graphicid& GI) const
+ {
-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de

Reply via email to