[Scummvm-devel] Problem with alignement with GCC
Lionel Ulmer
lionel.ulmer at free.fr
Sat Nov 10 02:38:02 CET 2001
Hi all,
I finally found out why ScummVM was not working properly on my iPAQ. The
fault lies in GCC's way of handling the '#pragma pack' directive.
I did some tests with the following test file :
#pragma pack (1)
struct toto {
char a;
int b;
};
#pragma pack ()
struct toti {
char a;
int b;
};
void main() {
printf("%d %d\n", sizeof(struct toto),sizeof(struct toti));
}
The results are :
5 8 with gcc 2.95.2 (built by myself on x86)
8 8 with gcc 2.95.4 (the Debian ARM package)
So to be 100 % sure to have the structure packed on any version of GCC, I
did the following change (see patch included against latest CVS version).
Anyway, there is also a typo in scummvm.cpp (also fixed by the patch :-) ) :
{"tentacle", "Day Of The Tenctacle", GID_TENTACLE, 6, 4, 2},
{"dottdemo", "Day Of The Tenctacle (Demo)", GID_TENTACLE, 6, 3, 2},
^^^
Now, I am going to see why the sound does not work on the iPAQ !
Lionel
--
Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
Index: scummsys.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scummsys.h,v
retrieving revision 1.11
diff -u -r1.11 scummsys.h
--- scummsys.h 2001/11/07 18:17:20 1.11
+++ scummsys.h 2001/11/10 10:35:09
@@ -53,6 +53,7 @@
#define START_PACK_STRUCTS pack (push,1)
#define END_PACK_STRUCTS pack(pop)
+#define GCC_PACK
#elif defined(UNIX)
@@ -74,10 +75,6 @@
#define FORCEINLINE inline
-#if defined(__GNUC__)
-#define NORETURN __attribute__((__noreturn__))
-#else
-#endif
#define CDECL
typedef unsigned char byte;
@@ -89,13 +86,21 @@
typedef signed short int16;
typedef signed long int32;
+#if defined(__GNUC__)
+#define START_PACK_STRUCTS
+#define END_PACK_STRUCTS
+#define GCC_PACK __attribute__((packed))
+#define NORETURN __attribute__((__noreturn__))
+#else
#define START_PACK_STRUCTS pack (1)
#define END_PACK_STRUCTS pack ()
+#define GCC_PACK
+#define NORETURN
+#endif
#else
#error No system type defined
#endif
-
#if defined(SCUMM_LITTLE_ENDIAN)
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm.h,v
retrieving revision 1.22
diff -u -r1.22 scumm.h
--- scumm.h 2001/11/09 18:54:14 1.22
+++ scumm.h 2001/11/10 10:35:11
@@ -34,12 +34,12 @@
struct Point {
int x,y;
-};
+} GCC_PACK;
struct AdjustBoxResult {
int16 x,y;
uint16 dist;
-};
+} GCC_PACK;
#define SIZEOF_BOX 20
struct Box { /* file format */
@@ -50,7 +50,7 @@
byte mask;
byte flags;
uint16 scale;
-};
+} GCC_PACK;
struct VerbSlot {
int16 x,y;
@@ -64,7 +64,7 @@
bool center;
uint8 field_1B;
uint16 imgindex;
-};
+} GCC_PACK;
struct VirtScreen {
int number;
@@ -77,7 +77,7 @@
uint16 xstart;
byte tdirty[40];
byte bdirty[40];
-};
+} GCC_PACK;
struct ActorWalkData {
int16 destx,desty;
@@ -88,7 +88,7 @@
int16 x,y,newx,newy;
int32 XYFactor, YXFactor;
uint16 xfrac,yfrac;
-};
+} GCC_PACK;
struct CostumeData {
uint16 hdr;
@@ -96,13 +96,13 @@
byte animCounter2;
byte x_1;
uint16 a[16], b[16], c[16], d[16];
-};
+} GCC_PACK;
struct MouseCursor {
int8 hotspot_x, hotspot_y;
byte colors[4];
byte data[32];
-};
+} GCC_PACK;
struct ScriptSlot {
uint32 offs;
@@ -114,17 +114,17 @@
byte unk1,unk2,freezeCount,didexec;
byte cutsceneOverride;
byte unk5;
-};
+} GCC_PACK;
struct NestedScript {
uint16 number;
uint8 type;
uint8 slot;
-};
+} GCC_PACK;
struct ResHeader {
uint32 size;
-};
+} GCC_PACK;
class ObjectData {
public:
@@ -142,13 +142,13 @@
byte ownerstate;
byte fl_object_index;
byte unk_3;
-};
+} GCC_PACK;
struct RoomHeader {
uint32 tag, size;
uint16 width,height;
uint16 numObjects;
-};
+} GCC_PACK;
struct CodeHeader {
uint32 id;
@@ -174,7 +174,7 @@
byte actordir;
} v6;
};
-};
+} GCC_PACK;
struct ImageHeader { /* file format */
uint32 id;
@@ -187,7 +187,7 @@
struct {
int16 x,y;
} hotspot[15];
-};
+} GCC_PACK;
#pragma END_PACK_STRUCTS
@@ -1668,4 +1668,4 @@
void blit(byte *dst, byte *src, int w, int h);
byte *findResource(uint32 id, byte *searchin, int index);
void playSfxSound(void *sound, uint32 size, uint rate);
-bool isSfxFinished();
\ No newline at end of file
+bool isSfxFinished();
Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scummvm.cpp,v
retrieving revision 1.22
diff -u -r1.22 scummvm.cpp
--- scummvm.cpp 2001/11/09 18:54:15 1.22
+++ scummvm.cpp 2001/11/10 10:35:11
@@ -415,8 +415,8 @@
{"monkey2", "Monkey Island 2: LeChuck's revenge", GID_MONKEY2, 5, 2, 2},
{"atlantis", "Indiana Jones 4 and the Fate of Atlantis", GID_INDY4, 5, 5, 0},
{"playfate", "Indiana Jones 4 and the Fate of Atlantis (Demo)", GID_INDY4, 5, 5, 0},
- {"tentacle", "Day Of The Tenctacle", GID_TENTACLE, 6, 4, 2},
- {"dottdemo", "Day Of The Tenctacle (Demo)", GID_TENTACLE, 6, 3, 2},
+ {"tentacle", "Day Of The Tentacle", GID_TENTACLE, 6, 4, 2},
+ {"dottdemo", "Day Of The Tentacle (Demo)", GID_TENTACLE, 6, 3, 2},
{"samnmax", "Sam & Max", GID_SAMNMAX, 6, 4, 2},
{"snmdemo", "Sam & Max (Demo)", GID_SAMNMAX, 6, 3, 0},
{NULL,NULL}
More information about the Scummvm-devel
mailing list